fix(server): ignore removed experiments during name uniqueness check #5360
+35
−0
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 #4336
Proposed changes
This PR fixes a bug where updating an experiment would fail with a "Duplicate Name" error if a deleted experiment existed with the same name.
Changes:
Modified the database query in the UpdateChaosExperiment handler.
Added a filter to exclude experiments where is_removed: true (or deleted_at is not null) during the name uniqueness check.
Types of changes
[ ] New feature (non-breaking change which adds functionality)
[x] Bugfix (non-breaking change which fixes an issue)
[ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
[ ] Documentation Update (if none of the other choices applies)
Checklist
[x] I have read the CONTRIBUTING doc
[x] I have signed the commit for DCO to be passed.
[x] Lint and unit tests pass locally with my changes
[x] I have added tests that prove my fix is effective or that my feature works (if appropriate)
[ ] I have added necessary documentation (if appropriate)
Dependency
None
Special notes for reviewer:
Verification (The "Ghost Test"): I verified this locally on a K8s cluster:
Created an experiment named Ghost-Test.
Deleted Ghost-Test.
Created a new experiment named Ghost-Test (this worked previously).
The Fix: Successfully updated the new Ghost-Test (added tags/description). Before this fix, this step failed with a duplicate error.