Fix critical bugs in Superposition: makefile syntax, division by zero, and typos #720
+44
−39
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.
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
TargetThe
superposition_legacy
target had unmatched quotes across multiple lines (165-168), causing the build to fail: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:experiment_groups/helpers.rs
: Added validation inassign_additional_buckets()
and early return inunassign_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 referencemonaco.languages.CompletionItemKind.Enum
to prevent breakage with future Monaco editor versions.Code Quality Improvements
Variable Naming Typos
Fixed
varaint
/varaints
→variant
/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:
occured
→occurred
(3 instances)recieved
→received
(1 instance)unqiue
→unique
(1 instance)atleast
→at least
(1 instance)Testing
All changes have been verified:
cargo check --workspace
passescargo test --workspace --lib
passes (15 tests)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
💡 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.