-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bug(sdk): context.OutputData assumed to be JSON #540
Comments
Looking at the MQTT trigger, could also check against the content itself to decide between JSON and CBOR like so: |
Configuring content type and defaulting to JSON would also work, either as its own field on MessageBusConfig or via Optional. |
I've done this by configuring "OutputContentType" through MessageBus.Optional for now, but suspect it will be best to include more flexibility in the future. Another option that I am coming to prefer might be to make content type available on the context and change OutputData to an interface{}. Then marshaling could be done by the SDK immediately prior to publication and spare the user from needing to match the configured content type in their application code. |
We'll take a closer look at this to figure out the best solution. It won't be included for Hanoi, but should be in our next release. |
This seems like a fine way to address the issue to me: d7502e4 Happy to submit a PR to add "context.ResponseContentType" awareness to the remaining triggers if there are no plans for something else in the works. |
@AlexCuse That would be great! |
Looks like it was only needed for the messagebus trigger since MQTT leaves marshaling entirely to the user. |
When a messagebus function pipeline completes, the marshaled byte array is assumed to be JSON. See: https://github.com/edgexfoundry/app-functions-sdk-go/blob/master/internal/trigger/messagebus/messaging.go#L111-L124
Not sure if this behavior is by design or not but looking at other messagebus code it appears to be a bug. Passing content type to the complete method looks simple enough, but I have some concern about changing signature of .Complete. Another way to do it might be to make the SDK aware of the content type in use (defaulting to JSON) and propagating that through trigger initialization as needed. I think I probably favor the latter approach, but I can't really think of a use case for varying the content type on a per message basis and may be missing something.
The text was updated successfully, but these errors were encountered: