juspay/hyperswitch
View on GitHub[FIX] Change Not Found Response to Internal Server Error for Empty Vector
Open
#5,916 opened on Sep 16, 2024
A-paymentsC-bugC-refactorS-awaiting-triagegood first issuehacktoberfest
Description
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_responseerror handler with one that returns anInternal Server Error (500)when an empty vector is encountered in intent_status_with_count. - Use
attach_printableto 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
Submission Process:
- Ask the maintainers for assignment of the issue, you can request for assignment by commenting on the issue itself.
- Once assigned, submit a pull request (PR).
- Maintainers will review and provide feedback, if any.
- Maintainers can unassign issues due to inactivity, read more here.
Refer here for Terms and conditions for the contest.