revk / NOTSCO

One Touch Switching test system
Other
9 stars 1 forks source link

500 Internal Server Error if switchOrderReference is not a valid UUID #17

Closed slimey99uk closed 2 months ago

slimey99uk commented 2 months ago

Not sure if you'll want to fix this, but I wasn't sending a valid UUID as switchOrderReference (because correlationID doesn't need to be a UUID I stupidly assumed the same was true for switchOrderReference), and was getting 500 Internal Server Error back from the letterbox endpoint, rather than a 400 error (ideally with some text about what was wrong) as per the API spec.

Tx:

{"residentialSwitchMatchConfirmation":{"matchResult":{"switchOrderReference":"SwitchResult_29249_1724655316","services":[{"serviceType":"IAS","switchAction":"ServiceFound","serviceIdentifiers":[{"identifierType":"ServiceInformation","identifier":"Bogons provided FWA service (FWA00577)"}]}]},"implicationsSent":[{"sentTo":"s****@slimey.org","sentBy":"2024-08-26 07:55:16","sentMethod":"email"}]},"envelope":{"destination":{"identity":"TEST","correlationID":"853eddb0-6326-11ef-8eb0-525400e5b6f9","type":"RCPID"},"routingID":"residentialSwitchMatchConfirmation","source":{"identity":"RVTV","correlationID":"26a8ee2a-6378-11ef-9e63-ce2ec55ca381","type":"RCPID"}}}

Rx:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>500 Internal Server Error</title>
</head><body>
<h1>Internal Server Error</h1>
<p>The server encountered an internal error or
misconfiguration and was unable to complete
your request.</p>
<p>Please contact the server administrator at
 [no address given] to inform them of the time this error occurred,
 and the actions you performed just before this error.</p>
<p>More information about this error may be available
in the server error log.</p>
<hr>
<address>Apache/2.4.61 (Debian) Server at otshub.notsco.co.uk Port 443</address>
</body></html>
revk commented 2 months ago

Yes, I want to fix it... Leave with me.

revk commented 2 months ago

Should be fixed, please retest, thanks.

slimey99uk commented 2 months ago

Confirmed working - now get a 202 response, and a warning in the message log on NOTSCO

revk commented 2 months ago

Hmm, it probably should have sent an error response back, or as you say, an 4xx error. But at least it is not crashing and says there is an issue. I'll see if I can improve that anyway.

revk commented 2 months ago

Ah, it can't send an error back as it is a Confirmation, OK, so probably right. We don't syntax check at that level in the "post" handling, and may well be the case with other CPs. So yeh, I think this is sane.