Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Change Not Found Response to Internal Server Error for Empty Vector #5916

Open
2 tasks done
apoorvdixit88 opened this issue Sep 16, 2024 · 0 comments
Open
2 tasks done
Labels
A-payments Area: payments C-bug Category: Bug C-refactor Category: Refactor good first issue Good for newcomers S-awaiting-triage Status: New issues that have not been assessed yet

Comments

@apoorvdixit88
Copy link
Contributor

apoorvdixit88 commented Sep 16, 2024

Feature Description

In the get_aggregates_for_payments function, when querying the database using the get_intent_status_with_count method, the function currently returns a Not Found response when an empty vector is encountered.
The not found case will never arise since we will be getting empty vector in such cases.

Since this scenario represents an internal logic issue rather than a missing payment, we should update the function to return an Internal Server Error instead.

let intent_status_with_count = db
    .get_intent_status_with_count(merchant.get_id(), profile_id_list, &time_range)
    .await
    .to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)?;

Possible Implementation

  • Replace the to_not_found_response error handler with one that returns an Internal Server Error (500) when an empty vector is encountered in intent_status_with_count.
  • Use attach_printable to attach a descriptive error message when an error occurs in fetching payment aggregates.

Have you spent some time checking if this feature request has been raised before?

  • I checked and didn't find a similar issue

Have you read the Contributing Guidelines?

Are you willing to submit a PR?

None

@apoorvdixit88 apoorvdixit88 added C-bug Category: Bug S-awaiting-triage Status: New issues that have not been assessed yet C-refactor Category: Refactor good first issue Good for newcomers A-payments Area: payments labels Sep 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-payments Area: payments C-bug Category: Bug C-refactor Category: Refactor good first issue Good for newcomers S-awaiting-triage Status: New issues that have not been assessed yet
Projects
None yet
Development

No branches or pull requests

1 participant