{"record":{"id":"ba83e3c4ea2025a4","repo":"vllm-project/vllm","slug":"parameter-must-be-in-expected-got-value","errorCode":null,"errorMessage":"{parameter} must be in {expected}, got {value}","messagePattern":"(.+?) must be in (.+?), got (.+?)","errorType":"validation","errorClass":"SamplingParamsError","httpStatus":400,"severity":"error","filePath":"rust/src/text/src/lower/sampling.rs","lineNumber":11,"sourceCode":"// SPDX-License-Identifier: Apache-2.0\n// SPDX-FileCopyrightText: Copyright contributors to the vLLM project\n\nuse thiserror::Error;\nuse vllm_engine_core_client::protocol::sampling::EngineCoreSamplingParams;\n\n#[derive(Debug, Error, PartialEq)]\npub enum SamplingParamsError {\n    #[error(\"{parameter} must be a finite number, got {value}\")]\n    NotFinite { parameter: &'static str, value: f32 },\n    #[error(\"{parameter} must be in {expected}, got {value}\")]\n    OutOfRange {\n        parameter: &'static str,\n        value: f32,\n        expected: &'static str,\n    },\n}\n\nfn validate_frequency_penalty(value: f32) -> Result<(), SamplingParamsError> {\n    validate_closed_range(\"frequency_penalty\", value, -2.0, 2.0, \"[-2, 2]\")\n}\n\nfn validate_presence_penalty(value: f32) -> Result<(), SamplingParamsError> {\n    validate_closed_range(\"presence_penalty\", value, -2.0, 2.0, \"[-2, 2]\")\n}\n\nfn validate_temperature(value: f32) -> Result<(), SamplingParamsError> {\n    validate_finite(\"temperature\", value)?;\n    validate_closed_range(\"temperature\", value, 0.0, 2.0, \"[0, 2]\")","sourceCodeStart":1,"sourceCodeEnd":29,"githubUrl":"https://github.com/vllm-project/vllm/blob/c794754062d49a8fdb63ab3c5215b488b865030c/rust/src/text/src/lower/sampling.rs#L1-L29","documentation":"Range validation in rust/src/text/src/lower/sampling.rs: temperature must be [0, 2]; top_p in (0, 1]; min_p [0, 1]; frequency_penalty and presence_penalty [-2, 2]; repetition_penalty (0, inf). The message names the parameter, its value, and the expected interval. Request-validation error.","triggerScenarios":"Sending temperature=3.0, top_p=0.0 or 1.5, min_p=1.2, frequency/presence_penalty outside [-2,2], or repetition_penalty=0.0/negative in a request. Note top_p=0 is rejected (open lower bound) and repetition_penalty must be strictly positive.","commonSituations":"Copying 'greedy' configs that use top_p=0 (should be temperature=0 instead); penalty values scaled from a -5..5 convention; unit mismatches (percent 50 vs 0.5 for min_p).","solutions":["Clamp each parameter to its stated interval before sending (temperature [0,2], top_p (0,1], min_p [0,1], penalties [-2,2], repetition_penalty > 0)","For greedy decoding use temperature=0.0, not top_p=0","For no penalty/repetition effect use 0.0 penalties and repetition_penalty=1.0"],"exampleFix":"# before\ntemperature = 3.0\ntop_p = 0\n\n# after\ntemperature = 0.0  # greedy\ntop_p = 1.0        # disabled","handlingStrategy":"validation","validationCode":"fn in_range(v: f32, lo: f32, hi: f32) -> bool { v >= lo && v <= hi }\nassert!(in_range(temperature, 0.0, 2.0));\nassert!(top_p > 0.0 && top_p <= 1.0);\nassert!(in_range(min_p, 0.0, 1.0));\nassert!(in_range(frequency_penalty, -2.0, 2.0));\nassert!(in_range(presence_penalty, -2.0, 2.0));\nassert!(repetition_penalty > 0.0);","typeGuard":"fn is_out_of_range(e: &Error) -> bool {\n    matches!(e, Error::SamplingParams(SamplingParamsError::OutOfRange { .. }))\n}","tryCatchPattern":"match err {\n    Error::SamplingParams(SamplingParamsError::OutOfRange { parameter, value, expected }) =>\n        bad_request(format!(\"{parameter}={value} not in {expected}\")),\n    _ => /* ... */\n}","preventionTips":["Ship a shared clamp function for sampling params in your client","Use temperature=0 for greedy; neutral values are penalties=0 and repetition_penalty=1"],"tags":["rust","validation","sampling-params","vllm"],"backgroundTag":null,"analyzedSha":"c794754062d49a8fdb63ab3c5215b488b865030c","analyzedAt":"2026-08-14T21:17:39.825Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}