{"record":{"id":"64889a5a472aed43","repo":"vllm-project/vllm","slug":"parameter-must-be-a-finite-number-got-value","errorCode":null,"errorMessage":"{parameter} must be a finite number, got {value}","messagePattern":"(.+?) must be a finite number, got (.+?)","errorType":"validation","errorClass":"SamplingParamsError","httpStatus":400,"severity":"error","filePath":"rust/src/text/src/lower/sampling.rs","lineNumber":9,"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> {","sourceCodeStart":1,"sourceCodeEnd":27,"githubUrl":"https://github.com/vllm-project/vllm/blob/c794754062d49a8fdb63ab3c5215b488b865030c/rust/src/text/src/lower/sampling.rs#L1-L27","documentation":"`validate_resolved_sampling_params` (rust/src/text/src/lower/sampling.rs:59-75) applies a finiteness check to `temperature` and `repetition_penalty`; NaN or +/-inf produces `NotFinite`. Other float params are caught by their range checks instead. This mirrors Python vLLM's sampling-param validation and is a request-validation error.","triggerScenarios":"Sending `temperature: NaN` / `Infinity` or `repetition_penalty: inf` (e.g. JSON `NaN`/`Infinity` literals or Rust f32::NAN) in a request; defaults are applied first, so unset fields never trigger it.","commonSituations":"Client-side math producing NaN (0.0/0.0, log(0) scaling) and passing it straight into temperature; JSON encoders that emit non-standard NaN/Infinity tokens; porting code from runtimes where NaN silently means 'default'.","solutions":["Sanitize floats before sending: reject or default NaN/inf values","Compute temperature with clamping, e.g. f32::clamp(0.0, 2.0) after arithmetic"],"exampleFix":"// before\nlet temp = raw_score / count; // may be NaN\nreq.temperature = Some(temp);\n\n// after\nlet temp = (raw_score / count).clamp(0.0, 2.0);\nreq.temperature = if temp.is_finite() { Some(temp) } else { None };","handlingStrategy":"validation","validationCode":"for (name, v) in [(\"temperature\", temperature), (\"repetition_penalty\", repetition_penalty)] {\n    if let Some(v) = v {\n        assert!(v.is_finite(), \"{name} must be finite, got {v}\");\n    }\n}","typeGuard":"fn is_not_finite(e: &Error) -> bool {\n    matches!(e, Error::SamplingParams(SamplingParamsError::NotFinite { .. }))\n}","tryCatchPattern":"match err {\n    Error::SamplingParams(SamplingParamsError::NotFinite { parameter, .. }) =>\n        bad_request(format!(\"{parameter} was NaN/inf; send a finite value or omit it\")),\n    _ => /* ... */\n}","preventionTips":["Clamp or default non-finite floats before any request","Validate JSON payloads rejecting non-standard NaN/Infinity literals at the parser"],"tags":["rust","validation","sampling-params","vllm"],"backgroundTag":null,"analyzedSha":"c794754062d49a8fdb63ab3c5215b488b865030c","analyzedAt":"2026-08-14T21:17:39.825Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}