Skip to content

fix(chaos-experiment): return weightages from latest revision in GetExperiment and ListExperiment#5556

Open
mugiwaraluffy56 wants to merge 1 commit into
litmuschaos:masterfrom
mugiwaraluffy56:fix/experiment-weightages-revision-index-check
Open

fix(chaos-experiment): return weightages from latest revision in GetExperiment and ListExperiment#5556
mugiwaraluffy56 wants to merge 1 commit into
litmuschaos:masterfrom
mugiwaraluffy56:fix/experiment-weightages-revision-index-check

Conversation

@mugiwaraluffy56

@mugiwaraluffy56 mugiwaraluffy56 commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Proposed changes

Found a bug where GetExperiment and ListExperiment were checking Revision[0].Weightages != nil (first/oldest revision) but then reading from Revision[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.

image

Types of changes

  • New feature (non-breaking change which adds functionality)
  • Bugfix (non-breaking ch
  • 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

  • I have read the CONTRIBUTING doc
  • I have signed the commit for DCO to be passed.
  • Lint and unit tests pas
  • 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 your rev

Two occurrences of the same bug, GetExperiment and ListExperiment. Both fixed the same way.

Signed-off-by: puneeth_aditya_5656 <myakampuneeth@gmail.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 GetExperiment and ListExperiment to 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants