Fix: Backend config initializer to_existing_atom calls fixed #87
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #85 , tests passing locally.
The bug comes from this code in the supervisor:
String.to_existing_atom/1
is trying to create atoms that do not exist at runtime. Replacing this withString.to_atom/1
does the trick.String.to_atom/1
is naughty in cases in which dynamic user input is being atomized or when a number of values being atomized are dynamic or large for some other reason because we have a finite number of atoms available to us on the BEAM, but this is neither of those cases.Because the atom being created in this code is from user configuration,
String.to_existing_atom/1
isn't necessary here because it is highly unlikely someone will DDoS their atom memory from their own user configuration of Hammer, as that would require passing a list of hundreds of thousands to millions of backends to their Hammer configuration, an unlikely case that indicates a bigger problem outside of the code.An alternative solution to this would be instantiating a list of possible atoms prior to this and using them in a way in which they don't get swept away, which would mean updating the list of usable backends in Hammer's source whenever someone develops a new one, a rather limiting condition.