Skip to content

Conversation

Copilot
Copy link

@Copilot Copilot AI commented Oct 6, 2025

Overview

This PR fixes multiple critical bugs discovered across the Superposition codebase, including makefile syntax errors, potential runtime panics, and code quality issues.

Critical Bug Fixes

1. Makefile Syntax Error in superposition_legacy Target

The superposition_legacy target had unmatched quotes across multiple lines (165-168), causing the build to fail:

# Before (broken)
superposition_legacy: CARGO_FLAGS += --features='$(FEATURES)
superposition_legacy: CARGO_FLAGS += superposition_types/disable_db_data_validation
superposition_legacy: CARGO_FLAGS += context_aware_config/disable_db_data_validation
superposition_legacy: CARGO_FLAGS += experimentation_platform/disable_db_data_validation'

# After (fixed)
superposition_legacy: CARGO_FLAGS += --features='$(FEATURES) superposition_types/disable_db_data_validation context_aware_config/disable_db_data_validation experimentation_platform/disable_db_data_validation'

2. Division by Zero Vulnerabilities

Fixed three locations where empty variant lists would cause panic at runtime:

experiment_ramp_form.rs: Added safety check when calculating range_max:

// Before (panic on empty variants)
let range_max = 100 / experiment.variants.len();

// After (safe)
let range_max = if experiment.variants.len() > 0 {
    100 / experiment.variants.len()
} else {
    100
};

experiment_groups/helpers.rs: Added validation in assign_additional_buckets() and early return in unassign_excess_buckets() to prevent division by zero when variants list is empty.

3. Curl Retry Configuration

Enhanced curl retry behavior by adding --retry-connrefused flag to ensure proper retries on connection refused errors, which the --retry-all-errors flag alone doesn't handle consistently. Removed misleading FIXME comments.

4. Monaco Editor Tight Coupling

Replaced magic number 15 with proper constant reference monaco.languages.CompletionItemKind.Enum to prevent breakage with future Monaco editor versions.

Code Quality Improvements

Variable Naming Typos

Fixed varaint/varaintsvariant/variants across 5 files:

  • crates/frontend/src/components/experiment_form.rs
  • postman/experimentation-platform/Create Experiment/event.test.js
  • postman/experimentation-platform/Create Experiment 2/event.test.js
  • postman/experimentation-platform/Update Override Keys/event.test.js

Spelling Corrections

Fixed spelling errors in error messages and comments:

  • occuredoccurred (3 instances)
  • recievedreceived (1 instance)
  • unqiueunique (1 instance)
  • atleastat least (1 instance)

Testing

All changes have been verified:

  • cargo check --workspace passes
  • cargo test --workspace --lib passes (15 tests)
  • ✅ No clippy warnings in main crates
  • ✅ Frontend compiles successfully
  • ✅ Makefile targets generate correct commands

Files Modified

  • makefile
  • crates/frontend/src-js/utils.js
  • crates/frontend/src/components/experiment_form.rs
  • crates/frontend/src/components/experiment_ramp_form.rs
  • crates/frontend/src/components/context_form.rs
  • crates/frontend/src/components/variant_form.rs
  • crates/frontend/src/pages/home.rs
  • crates/experimentation_platform/src/api/experiment_groups/helpers.rs
  • crates/experimentation_platform/src/api/experiments/handlers.rs
  • crates/context_aware_config/src/api/functions/handlers.rs
  • postman/experimentation-platform/Create Experiment/event.test.js
  • postman/experimentation-platform/Create Experiment 2/event.test.js
  • postman/experimentation-platform/Update Override Keys/event.test.js

All changes maintain backward compatibility and follow minimal-change principles.

Original prompt

fix all bugs in superposition and raise a PR to main


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@Copilot Copilot AI changed the title [WIP] fix all bugs in superposition and raise a PR to main Fix critical bugs in Superposition: makefile syntax, division by zero, and typos Oct 6, 2025
@Copilot Copilot AI requested a review from Datron October 6, 2025 09:39
Copilot finished work on behalf of Datron October 6, 2025 09:39
Comment on lines +28 to +32
let range_max = if experiment.variants.len() > 0 {
100 / experiment.variants.len()
} else {
100
};
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
let range_max = if experiment.variants.len() > 0 {
100 / experiment.variants.len()
} else {
100
};
let range_max = 100 / experiment.variants.len();

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.

3 participants