{"record":{"id":"05c5bef2d792530b","repo":"risingwavelabs/risingwave","slug":"invalid-value-for-ratio-strategy-must-be-between","errorCode":null,"errorMessage":"Invalid value for Ratio strategy: must be between 0.0 and 1.0","messagePattern":"Invalid value for Ratio strategy: must be between 0\\.0 and 1\\.0","errorType":"validation","errorClass":"ParallelismStrategyParseError","httpStatus":null,"severity":"error","filePath":"src/common/src/system_param/adaptive_parallelism_strategy.rs","lineNumber":76,"sourceCode":"        val.to_string()\n    }\n}\n\n#[derive(Error, Debug)]\npub enum ParallelismStrategyParseError {\n    #[error(\"Unsupported strategy: {0}\")]\n    UnsupportedStrategy(String),\n\n    #[error(\"Parse error: {0}\")]\n    ParseIntError(#[from] std::num::ParseIntError),\n\n    #[error(\"Parse error: {0}\")]\n    ParseFloatError(#[from] std::num::ParseFloatError),\n\n    #[error(\"Invalid value for Bounded strategy: must be positive integer\")]\n    InvalidBoundedValue,\n\n    #[error(\"Invalid value for Ratio strategy: must be between 0.0 and 1.0\")]\n    InvalidRatioValue,\n}\n\nimpl AdaptiveParallelismStrategy {\n    pub fn compute_target_parallelism(&self, current_parallelism: usize) -> usize {\n        match self {\n            AdaptiveParallelismStrategy::Auto | AdaptiveParallelismStrategy::Full => {\n                current_parallelism\n            }\n            AdaptiveParallelismStrategy::Bounded(n) => min(n.get(), current_parallelism),\n            AdaptiveParallelismStrategy::Ratio(r) => {\n                max((current_parallelism as f32 * r).floor() as usize, 1)\n            }\n        }\n    }\n}\n\npub fn parse_strategy(","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/common/src/system_param/adaptive_parallelism_strategy.rs#L58-L94","documentation":"ParallelismStrategyParseError::InvalidRatioValue is thrown when the float argument to the Ratio parallelism strategy parses but is outside the valid range [0.0, 1.0]. Ratio expresses a target fraction of current parallelism, so values like 1.5 or -0.1 are semantically meaningless and rejected with this fixed message.","triggerScenarios":"Setting the adaptive parallelism strategy to 'ratio(1.5)' or 'ratio(-0.1)' — a valid float that violates the 0.0 <= value <= 1.0 range check.","commonSituations":"Using a percentage number directly (ratio(50) instead of ratio(0.5)); thinking ratio is a multiplier > 1; sign errors in computed values.","solutions":["Clamp the value to [0.0, 1.0] and re-set, e.g. 'ratio(0.5)'.","Convert percentages to fractions before setting (50% -> 0.5).","For target parallelism greater than current, use 'bounded(n)' or 'auto' instead of ratio."],"exampleFix":"// before\nSET adaptive_parallelism_strategy = 'ratio(1.5)';\n// after\nSET adaptive_parallelism_strategy = 'ratio(0.5)';","handlingStrategy":"validation","validationCode":"// Clamp/validate ratio into [0.0, 1.0] before setting\nfn set_ratio(r: f32) -> Result<String, String> {\n    if !(0.0..=1.0).contains(&r) {\n        return Err(format!(\"ratio {r} outside [0.0, 1.0]\"));\n    }\n    Ok(format!(\"ratio({r})\"))\n}","typeGuard":null,"tryCatchPattern":"match result {\n    Err(ParallelismStrategyParseError::InvalidRatioValue) => {\n        eprintln!(\"ratio must be between 0.0 and 1.0 (convert percentages to fractions)\");\n    }\n    other => other?,\n}","preventionTips":["Always convert percentages to fractions before configuring.","Clamp user-supplied values with r.clamp(0.0, 1.0) in tooling.","Remember ratio targets a fraction of current parallelism; use bounded(n) for scale-up targets."],"tags":["config","parallelism","validation","range"],"backgroundTag":"argument-out-of-range","analyzedSha":"6469eb736d691e8e9b8a419a57edd6429ca77417","analyzedAt":"2026-09-11T21:06:21.487Z","contentChangedAt":"2026-09-11T21:06:21.487Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}