USACE / cwms-data-api

Corps Water Management System RESTful Data Service
MIT License
13 stars 14 forks source link

Pass INVALID_OFFICE_ID through on errors #943

Closed krowvin closed 3 days ago

krowvin commented 1 week ago

If a user does this https://cwms-data.usace.army.mil/cwms-data/timeseries?name=OMA.Temp-Water.Inst.1Hour.0.Best-NWDM&office=NWDW&unit=EN

They get this error

{"message":"System Error","incidentIdentifier":"-897878052613553257","details":{}}

Which is very cryptic.

In the actual logs I see this:

Msg = ORA-20010: INVALID_OFFICE_ID: "NWDW" is not a valid CWMS office id

The correct URL / OFFICE would be https://cwms-data.usace.army.mil/cwms-data/timeseries?name=OMA.Temp-Water.Inst.1Hour.0.Best-NWDM&office=NWDM&unit=EN

I.e. NWDM not NWDW - it's a mistake I made and another user made as well.

This could be said for other errors, but i'll just pop in as we find them!

Solution

A vague

{"error": "Invalid office id: <office-id>"}

is more helpful!

MikeNeilson commented 1 week ago

If the returned value is included it must be passed through the sanitizer. However, I do think it would be good to include, sometime you need the error message AND text for your brain to finally read the letters correctly.