fix(chaos-experiment): return weightages from latest revision in GetExperiment and ListExperiment#5556
Open
mugiwaraluffy56 wants to merge 1 commit into
Conversation
Signed-off-by: puneeth_aditya_5656 <myakampuneeth@gmail.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a revision-indexing bug in the chaos experiment GraphQL handlers where GetExperiment and ListExperiment gated weightage extraction using the oldest revision but then read weightages from the latest revision, causing latest weightages to be dropped for multi-revision experiments.
Changes:
- Update weightages nil-guards in
GetExperimentandListExperimentto check the latest revision (Revision[len-1]) consistently with the subsequent read. - Add regression tests covering multi-revision scenarios where weightages are added/removed across revisions for both code paths.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
chaoscenter/graphql/server/pkg/chaos_experiment/handler/handler.go |
Fixes the revision index used to guard/read weightages to consistently use the latest revision. |
chaoscenter/graphql/server/pkg/chaos_experiment/handler/handler_test.go |
Adds regression tests to ensure weightages returned match the latest revision in both Get and List handlers. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Proposed changes
Found a bug where
GetExperimentandListExperimentwere checkingRevision[0].Weightages != nil(first/oldest revision) but then reading fromRevision[len-1](latest revision). Two different indices.This breaks when an experiment has multiple revisions. If you create an experiment without weightages and then u check on the first revisionsilently drops the latest revision's weightages completely.
Fix is two lines, change both nil checks to guard against
Revision[len-1]which is what's actually being read. Added 3 regression testscovering the exact multi-revision scenarios that were broken.Types of changes
Checklist
Dependency
Special notes for your rev
Two occurrences of the same bug,
GetExperimentandListExperiment. Both fixed the same way.