department-of-veterans-affairs / notification-api

Notification API
MIT License
16 stars 9 forks source link

BUG: POST inbound-number 500 statuses on non-unique 'number' property #1574

Open cris-oddball opened 11 months ago

cris-oddball commented 11 months ago

Description

We return a 500 http status when posting a non-unique inbound-number and flood the logs (~100 lines just for this one error)

On the POST routes for /inbound-number, when passing a payload that includes a non-unique number, the service returns a 500 Internal Server Error, when we actually know what the problem is and should return a 400 status and a relevant error message indicting that the number is not unique.

Routes:

Steps to Reproduce

  1. Using POST /inbound-numberto create a new inbound-number in Postman, populate the number property with an existing number.
  2. Observe the 500 Internal Server Error response
  3. Using POST /inbound-number/:inbound_number-idto update an existing inbound-number in Postman, populate the number property with an existing number.
  4. Observe the 500 Internal Server Error response

Logs will show the stacetrace errors. Here are a few examples.

Screenshot 2023-12-20 at 11.30.43 AM.jpg Screenshot 2023-12-20 at 11.30.58 AM.jpg Screenshot 2023-12-20 at 11.31.27 AM.jpg

Workaround

Is there something we can do to work around this issue in the meantime? None. We just have to remember this is a possible issue when troubleshooting.

Impact/Urgency

Low - internal facing experience which causes confusion

Expected Behavior

When I POST to create or update an inbound number And I use a number that already exists on that service Then I should receive a 400 Bad Request response and an error message detailing what went wrong and the typical amount of logging for an error like this.

Possible example:

{
    "errors": [
        {
            "error": "ValidationError",
            "message": "number +15125551212 is not unique"
        }
    ],
    "status_code": 400
}

QA Considerations

For QA to populate. Leave blank if QA is not applicable on this ticket.

Additional Info & Resources

mjones-oddball commented 10 months ago

Hey team! Please add your planning poker estimate with Zenhub @cris-oddball @edDocMe360 @EvanParish @k-macmillan @kalbfled

npmartin-oddball commented 1 month ago

Keeping.