Skip to content
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

fix: trace formatter should not crash when given a non-binary payload #13140

Conversation

kjellwinblad
Copy link
Contributor

@kjellwinblad kjellwinblad commented May 28, 2024

Fixes:
https://emqx.atlassian.net/browse/EMQX-12474

Release version: v/e5.?

Summary

PR Checklist

Please convert it to a draft if any of the following conditions are not met. Reviewers may skip over until all the items are checked:

  • [] Added tests for the changes
  • [] Added property-based tests for code which performs user input validation
  • [] Changed lines covered in coverage report
  • Change log has been added to changes/(ce|ee)/(feat|perf|fix|breaking)-<PR-id>.en.md files
  • [] For internal contributor: there is a jira ticket to track this change
  • [] Created PR to emqx-docs if documentation update is required, or link to a follow-up jira ticket
  • [] Schema changes are backward compatible

@kjellwinblad kjellwinblad requested review from JimMoen, a team and lafirest as code owners May 28, 2024 08:40
@kjellwinblad kjellwinblad force-pushed the kjell/republish_trace_crash/EMQX-12474 branch from 42ec8ab to 2eb5c24 Compare May 28, 2024 09:09
emqx_packet:format(Packet, Encode)
catch
_:_ ->
%% We don't want to crash if there is a field named packet with
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you provide an example here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a trace that includes the output of a rule. As the the rule can output almost any map it can contain a field named packet. Not 100% sure if the key can be an atom in that case. Perhaps the optimal solution is to not look for the packet field in all levels of the map as we may only want to format it when it is in the top level. What do you think? The payload field is perhaps different since the user can change how it is formatted and will perhaps expect it to be formatted this way wherever it may be.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is ok.
I missed that this is done recursively.
maybe good to explain as comment.

Copy link
Contributor

@thalesmg thalesmg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✔️

Would it make sense to add a smoke test for this case?

@kjellwinblad
Copy link
Contributor Author

@thalesmg

Would it make sense to add a smoke test for this case?

It would not hurt. I added a task for this so I can pick it up later:

https://emqx.atlassian.net/browse/EMQX-12483

@zmstone

maybe good to explain as comment.

Also does not hurt. Will try to add this at the same time as I do the task above.

@kjellwinblad kjellwinblad merged commit 3769bbb into emqx:release-57 May 29, 2024
177 checks passed
@emqxqa
Copy link

emqxqa commented Jun 3, 2024

TestExecution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants