xmidt-org / wrp-go

go implementation of the Web Routing Protocol
Apache License 2.0
4 stars 7 forks source link

Setting msg_type field to unsupport value results in empty string Xmidt-Messag-Type header with delivered event. #67

Closed ilawjr closed 2 years ago

ilawjr commented 2 years ago

If you set the msg_type field to 2 (or another unsupported int value) the event is delivered with "X-Xmidt-Message-Type": [""]

  1. setup and register listener (example uses basin). Then submit event to caduceus such as:

example {"msg_type":2,"source":"dns:talaria.xmidt.example.com","dest":"event: xmidt-test","transaction_uuid": "9284a7ad-8cae-4cca-8b7d-dda69e2b0e62","content_type": "json","accept": "","status": 504,"rdr": 0,"headers": ["a:b","b:c","d:e"],"metadata": {"/boot-time":"1542834188","/last-reconnect-reason":"spanish inquisition"},"spans": [["Luke","Skywalker","1234", "5678","0"],["Lord","Vader","1234","5678","1"] ],"include_spans": true,"path": "/online","payload": "[redacted]","service_name": "qa","url":"updown","partner_ids":["comcast"],"session_id": "1wksX1ckVakUcgIzXh0S1sSHvK8"}

  1. retrieve event from listener.

{"Method": "POST", "URL": "/api/v1/responder", "Body": "[redacted]", "Headers": {"Accept-Encoding": ["gzip"], "Content-Length": ["164"], "Content-Type": ["json"], "User-Agent": ["Go-http-client/1.1"], "X-Webpa-Device-Id": ["dns:talaria.xmidt.example.com"], "X-Webpa-Device-Name": ["dns:talaria.xmidt.example.com"], "X-Webpa-Event": ["xmidt-test"], "X-Webpa-Signature": ["sha1=01c9014ea319ff29a5ffa2c6650a992bc9b1370b"], "X-Webpa-Transaction-Id": ["9284a7ad-8cae-4cca-8b7d-dda69e2b0e62"], "X-Xmidt-Include-Spans": ["true"], "X-Xmidt-Message-Type": [""], "X-Xmidt-Metadata": ["/boot-time=1542834188", "/last-reconnect-reason=spanish inquisition"], "X-Xmidt-Partner-Id": ["comcast"], "X-Xmidt-Path": ["/online"], "X-Xmidt-Request-Delivery-Response": ["0"], "X-Xmidt-Source": ["dns:talaria.xmidt.example.com"], "X-Xmidt-Span": ["Luke,Skywalker,1234,5678,0", "Lord,Vader,1234,5678,1"], "X-Xmidt-Status": ["504"], "X-Xmidt-Transaction-Uuid": ["9284a7ad-8cae-4cca-8b7d-dda69e2b0e62"]}}

The current expected behavior is undefined, and part of this issue will be to determine what we expect.

kristinapathak commented 2 years ago

I think if we get an unsupported event type, caduceus shouldn't try to deliver that event.

ilawjr commented 2 years ago

If we go that route, caduceus should probably reject the request with a 400.

As a side note, It looks like msg_type=11 results in Unknown.

kristinapathak commented 2 years ago

Discussed with @schmidtw and we think the best backwards compatible solution is to make enum values for 0, 1, and 2. 2 is meant to be for Authorization Status. 0 and 1 should both be Invalid. Since an enum cannot be two values, I think something like Invalid0 and Invalid1 should work? If possible, they can both result in the same string though.

Caduceus or any other service can check the MessageType after decoding the wrp to determine if it's valid. Caduceus is only interested in sending SimpleEvents so can return 400 for any other MessageType.