Skip to content

Conversation

J-Mx
Copy link
Contributor

@J-Mx J-Mx commented Jun 19, 2025

Pull Request (PR) description

See #1053 for a clear description of the issue. This PR fix arguments parsing and uniqueness while managing rabbitmq binding with puppet

This Pull Request (PR) fixes the following issues

Fixes #1053

@wyardley wyardley added the bug Something isn't working label Jun 19, 2025
Copy link
Contributor

@wyardley wyardley left a comment

Choose a reason for hiding this comment

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

Thanks for this! Looks good overall. Have you tested this locally? Any corner cases with escaping or quoting or security risks? In the case where the hash changes, will that trigger any changes for existing users of the module that have existing bindings?

As with a lot of stuff in this module, the real fix would probably be to deprecate older versions, get some of the other needed changes across the line, and switch to either using JSON output from the CLI, or using the API directly, but this makes sense, I think.

Just thinking aloud, but I wonder if it would be feasible to JSON parse the entire arguments string vs. trying to use regex to parse it?

@J-Mx J-Mx force-pushed the handle_arguments_and_fix_uniqueness branch from e9a3a45 to f78eee0 Compare June 20, 2025 14:21
@J-Mx J-Mx force-pushed the handle_arguments_and_fix_uniqueness branch from f78eee0 to 95d1e29 Compare June 20, 2025 14:36
@wyardley wyardley requested review from ekohl and bastelfreak June 20, 2025 15:18
@bastelfreak
Copy link
Member

Just thinking aloud, but I wonder if it would be feasible to JSON parse the entire arguments string vs. trying to use regex to parse it?

I think proper JSON parsing would make this so so much more readable.

@J-Mx
Copy link
Contributor Author

J-Mx commented Jun 20, 2025

Thank you for your review @wyardley. I have updated my branch to address your feedbacks.

Thanks for this! Looks good overall. Have you tested this locally? Any corner cases with escaping or quoting or security risks? In the case where the hash changes, will that trigger any changes for existing users of the module that have existing bindings?

There are no particular edge cases or potential security risks with these changes. Including 'arguments' in the binding hash name calculation prevents perpetual binding modifications. Previously, bindings with identical source, destination, vhost and routing_key but different arguments would generate the same hash, causing Puppet to continuously try to update them thinking they were the same binding. This change ensures that bindings with different arguments are correctly identified as distinct resources.

As with a lot of stuff in this module, the real fix would probably be to deprecate older versions, get some of the other needed changes across the line, and switch to either using JSON output from the CLI, or using the API directly, but this makes sense, I think.

As for parsing the arguments as JSON instead of using regex: it’s definitely possible, but it would require much more time and a significant refactor of the codebase compared to the fix proposed in this pull request. That said, it would likely help avoid these kinds of regex issues in the future.

Just thinking aloud, but I wonder if it would be feasible to JSON parse the entire arguments string vs. trying to use regex to parse it?

The format returned by rabbitmqctl is not parsable JSON code, but rather follows Erlang's tuple list syntax (e.g., [{"key","value"}]). This is why substitutions with regular expressions are present in the code to transform this Erlang format into a JSON-parsable format.

@wyardley wyardley merged commit 02d34df into voxpupuli:master Jun 20, 2025
17 checks passed
@wyardley
Copy link
Contributor

Thanks for the contribution. Will try to cut a release soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

rabbitmq_binding: arguments ignored due to regexp and uniqueness issues
3 participants