Skip to content

Comments

Fix #13748: Definition import should ignore the UTF-8 BOM of the uploade#15527

Open
danielalanbates wants to merge 1 commit intorabbitmq:mainfrom
danielalanbates:fix/issue-13748
Open

Fix #13748: Definition import should ignore the UTF-8 BOM of the uploade#15527
danielalanbates wants to merge 1 commit intorabbitmq:mainfrom
danielalanbates:fix/issue-13748

Conversation

@danielalanbates
Copy link

Fixes #13748

Summary

This PR fixes: Definition import should ignore the UTF-8 BOM of the uploaded file

Changes

deps/rabbit/src/rabbit_definitions.erl                      | 3 +++
 deps/rabbitmq_management/src/rabbit_mgmt_wm_definitions.erl | 3 +++
 2 files changed, 6 insertions(+)

Testing

Please review the changes carefully. The fix was verified against the existing test suite.


This PR was created with the assistance of Claude Sonnet 4.6 by Anthropic | effort: low. Happy to make any adjustments!

@michaelklishin
Copy link
Collaborator

@danielalanbates thank you. Have you signed our CLA? If not, please take a look at how that's done, it's a pretty straightforward process.

Thank you.

@danielalanbates
Copy link
Author

Thank you for the review! Glad it helps. 🙏

@michaelklishin
Copy link
Collaborator

This does not cover the CLI command and does not add any tests but it'll be trivial to do for someone who works on the definitions subsystem regularly (me), so I'll handle it for you.

@danielalanbates
Copy link
Author

Thank you for the review! Glad it helps. 🙏

@lukebakken lukebakken self-assigned this Feb 22, 2026
@lukebakken
Copy link
Collaborator

@michaelklishin see the discussion I stared in #core-team with regard to this, thanks.

@michaelklishin
Copy link
Collaborator

I'll wait for @lukebakken to review this PR (it's a part of a research study, not sure if it'd be OK for me to reveal any details).

@lukebakken
Copy link
Collaborator

Unfortunately I can't use the required software to record my review 😢

@michaelklishin
Copy link
Collaborator

@lukebakken so I am free to proceed to merge this once the CLA part is settled, or re-implement these changes myself? I'm not sure what that means per your agreement with [the org that conducts the study], sorry.

@lukebakken
Copy link
Collaborator

You can do whatever you like! I can't participate in that study. I do have some feedback for this PR, however, which I'll add now.

The UTF-8 BOM (byte order mark, EF BB BF) is a three-byte sequence that
some editors prepend to UTF-8 encoded files. The JSON parser does not
strip it automatically, causing definition import to fail with a JSON
parse error.

Add a pattern-match clause to the decode/1 functions in both
rabbit_definitions and rabbit_mgmt_wm_definitions to strip the BOM
before attempting to parse the body as JSON.
Copy link
Collaborator

@lukebakken lukebakken left a comment

Choose a reason for hiding this comment

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

See how I addressed this issue in Kyroai/cuttlefish. Note that it handles all UTF BOMs and includes tests.

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.

Definition import should ignore the UTF-8 BOM of the uploaded file

3 participants