Fix #13748: Definition import should ignore the UTF-8 BOM of the uploade#15527
Fix #13748: Definition import should ignore the UTF-8 BOM of the uploade#15527danielalanbates wants to merge 1 commit intorabbitmq:mainfrom
Conversation
|
@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. |
|
Thank you for the review! Glad it helps. 🙏 |
|
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. |
|
Thank you for the review! Glad it helps. 🙏 |
|
@michaelklishin see the discussion I stared in |
|
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). |
|
Unfortunately I can't use the required software to record my review 😢 |
|
@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. |
|
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.
2acf03e to
90e374c
Compare
lukebakken
left a comment
There was a problem hiding this comment.
See how I addressed this issue in Kyroai/cuttlefish. Note that it handles all UTF BOMs and includes tests.
Fixes #13748
Summary
This PR fixes: Definition import should ignore the UTF-8 BOM of the uploaded file
Changes
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!