{"record":{"id":"01ea20cd62317417","repo":"vllm-project/vllm","slug":"requested-logprob-token-ids-of-length-requested","errorCode":null,"errorMessage":"requested logprob_token_ids of length {requested}, which is greater than max allowed: {max_allowed}","messagePattern":"requested logprob_token_ids of length (.+?), which is greater than max allowed: (.+?)","errorType":"validation","errorClass":"LogprobsError","httpStatus":400,"severity":"error","filePath":"rust/src/text/src/lower/logprobs.rs","lineNumber":25,"sourceCode":"//! passed through to engine-core.\n\nuse thiserror::Error;\n\nuse crate::backend::SamplingLimits;\n\n#[derive(Debug, Error)]\npub enum LogprobsError {\n    #[error(\"{parameter} must be non-negative or -1, got {value}\")]\n    InvalidCount { parameter: &'static str, value: i32 },\n    #[error(\n        \"requested {parameter} of {requested}, which is greater than max allowed: {max_allowed}\"\n    )]\n    TooManyCount {\n        parameter: &'static str,\n        requested: usize,\n        max_allowed: usize,\n    },\n    #[error(\n        \"requested logprob_token_ids of length {requested}, \\\n         which is greater than max allowed: {max_allowed}\"\n    )]\n    TooManyTokenIds {\n        requested: usize,\n        max_allowed: usize,\n    },\n    #[error(\n        \"when both logprobs and logprob_token_ids are set, logprobs must equal \\\n         len(logprob_token_ids). Got logprobs={logprobs}, len(logprob_token_ids)={num_token_ids}.\"\n    )]\n    TokenIdsMismatch { logprobs: i32, num_token_ids: usize },\n}\n\n/// Validate logprobs count sampling parameters.\npub(super) fn validate_logprobs(\n    logprobs: Option<i32>,\n    prompt_logprobs: Option<i32>,","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/vllm-project/vllm/blob/c794754062d49a8fdb63ab3c5215b488b865030c/rust/src/text/src/lower/logprobs.rs#L7-L43","documentation":"`logprob_token_ids` (the list of specific token IDs to return logprobs for) exceeds the hard frontend cap `SamplingLimits::MAX_LOGPROB_TOKEN_IDS` (rust/src/text/src/lower/logprobs.rs:87-92). Unlike counts, this cap is a compile-time constant of the Rust text frontend, not a server knob.","triggerScenarios":"Passing a `logprob_token_ids` array longer than MAX_LOGPROB_TOKEN_IDS in a request.","commonSituations":"Building large curated token watch-lists (e.g. all tokens of several words); attempting to use logprob_token_ids as a full-vocabulary workaround when logprobs is capped.","solutions":["Trim logprob_token_ids to the cap; request only the token IDs you actually inspect","If you genuinely need broad coverage, use logprobs (top-K count) instead of an explicit ID list"],"exampleFix":"// before\nrequest.logprob_token_ids = all_vocab_ids; // huge list\n\n// after\nrequest.logprob_token_ids = watchlist.slice(0, MAX_LOGPROB_TOKEN_IDS);","handlingStrategy":"validation","validationCode":"const MAX_LOGPROB_TOKEN_IDS: usize = SamplingLimits::MAX_LOGPROB_TOKEN_IDS;\nassert!(logprob_token_ids.len() <= MAX_LOGPROB_TOKEN_IDS,\n    \"too many logprob_token_ids: {}\", logprob_token_ids.len());","typeGuard":"fn is_too_many_token_ids(e: &Error) -> bool {\n    matches!(e, Error::Logprobs(LogprobsError::TooManyTokenIds { .. }))\n}","tryCatchPattern":"match err {\n    Error::Logprobs(LogprobsError::TooManyTokenIds { requested, max_allowed }) =>\n        bad_request(format!(\"logprob_token_ids len {requested} > {max_allowed}\")),\n    _ => /* ... */\n}","preventionTips":["Keep logprob_token_ids a curated watch-list, not a vocabulary dump","Trim to the frontend constant before sending"],"tags":["rust","validation","logprobs","vllm"],"backgroundTag":null,"analyzedSha":"c794754062d49a8fdb63ab3c5215b488b865030c","analyzedAt":"2026-08-14T21:17:39.825Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}