Remove whitespace from level names to fix seeding #51968
Merged
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.
Seeding was failing on multiple environments with an error like:
Strangely, locally, seeding was successful once then failed consistently (with that error) after that. The back trace pointed to this line, ie
level.update!(name: data[:name], game_id: Game.find_by(name: to_s).id, properties: data[:properties], md5: md5)
. What was happening was that we strip whitespace from level names before validation (and, therefore, before save). However, a couple of lines before the failing line we dolevel = find_or_create_by({name: data[:name]})
without stripping whitespace. This means that it was trying to create a new level with whitespace in the name then, when it went to save that, had a conflict on the name field, with itself.There's a longer term fix here that I can likely get out today but this should unblock the builds now.