xmidt-org / tr1d1um

Tr1d1um is the Webpa micro-service that encode TR-181 requests.
Apache License 2.0
12 stars 13 forks source link

Tr1d1um Panic: device status code used as the response status code can cause an unrecoverable panic #354

Closed denopink closed 1 year ago

denopink commented 1 year ago

Tr1d1um panics when a device status code is either 100 or is an invalid http status code.

Currently, we don't reuse the following device status codes as our response status code: 0, 500.

Related code: https://github.com/xmidt-org/tr1d1um/blob/ebd7188498832190b47a166e5ca7927d0baaf298/translation/transport.go#L213-L219

Our current documentation @ https://github.com/xmidt-org/xmidt/wiki/XMiDT-API states the following:

Responses

Status Description
200 Request successful
403 Forbidden
404 Device Not Found
500 The XMiDT cloud had an issue
503 A XMiDT cloud component did not respond in the allowed time
504 The device did not respond in the allowed time
599 If XMiDT was able to transfer the request and response but the device reported a non-2xx status (see WRP.status_code in message or header)

Questions:

JC000 commented 1 year ago

If we are to change this behavior (return a status code other than what is documented), we need to remember to update that page.

If memory serves, my conversation with Wes had us agreeing that anything between 520 and 599 (inclusive) would be usable by RDK, and that we can use that value directly in the Tridium response. We need to verify that this was communicated to RDK and that their implementations uses this range.

schmidtw commented 1 year ago

Yes, that's the right range (520-599 inclusive). Here is the code that produces the error codes for webpa: https://github.com/xmidt-org/wdmp-c/blob/317d79cadf2fd61031b7b553d5b5548c25d03f9d/src/wdmp_internal.h#L32