{"record":{"id":"73f1298295faa930","repo":"vllm-project/vllm","slug":"text-request-request-id-must-contain-at-least","errorCode":null,"errorMessage":"text request `{request_id}` must contain at least one prompt token ID","messagePattern":"text request `(.+?)` must contain at least one prompt token ID","errorType":"validation","errorClass":"Error","httpStatus":400,"severity":"error","filePath":"rust/src/text/src/error.rs","lineNumber":16,"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::Error as EngineCoreError;\nuse vllm_llm::Error as LlmError;\n\npub use crate::lower::logprobs::LogprobsError;\npub use crate::lower::sampling::SamplingParamsError;\npub use crate::lower::token_ids::TokenIdsError;\n\n#[derive(Debug, Error)]\npub enum Error {\n    #[error(\"tokenizer error: {0}\")]\n    Tokenizer(String),\n    #[error(\"text request `{request_id}` must contain at least one prompt token ID\")]\n    EmptyPromptTokenIds { request_id: String },\n    #[error(\"text request `{request_id}` stop strings cannot be empty\")]\n    EmptyStopString { request_id: String },\n    #[error(\n        \"this model's maximum context length is {max_model_len} tokens, \\\n         but the prompt contains {prompt_len} input tokens\"\n    )]\n    PromptTooLong { max_model_len: u32, prompt_len: u32 },\n    #[error(transparent)]\n    Logprobs(#[from] LogprobsError),\n    #[error(transparent)]\n    TokenIds(#[from] TokenIdsError),\n    #[error(transparent)]\n    SamplingParams(#[from] SamplingParamsError),\n    #[error(\n        \"`min_tokens` must be less than or equal to `max_tokens`, \\\n         got min_tokens={min_tokens}, max_tokens={max_tokens}\"\n    )]","sourceCodeStart":1,"sourceCodeEnd":34,"githubUrl":"https://github.com/vllm-project/vllm/blob/c794754062d49a8fdb63ab3c5215b488b865030c/rust/src/text/src/error.rs#L1-L34","documentation":"Error variant raised in rust/src/text/src/request.rs:228 when a text request supplies prompt_token_ids that is empty. The frontend requires at least one prompt token before it can lower the request to the engine. is_request_validation_error() classifies it as an invalid user request (400-class), so the HTTP layer maps it to a client error, not a server fault.","triggerScenarios":"POST /v1/completions (or the internal text API) with \"prompt_token_ids\": [] and no text prompt; a client sending an empty string prompt that tokenizes to zero tokens; a gateway forwarding a tokenized request built from empty input.","commonSituations":"Programmatic clients building token-id requests from a variable that ended up empty; upstream chunking/splitting logic producing zero-length segments; prompt preprocessing that strips everything (e.g. whitespace-only prompt with a tokenizer that yields no tokens).","solutions":["Send a non-empty prompt, or at least one token ID when using prompt_token_ids.","Guard in client code: skip or reject empty inputs before calling the API.","If the prompt is legitimately whitespace-only, check what your tokenizer yields and send minimal content instead."],"exampleFix":"// before\nrequest.prompt_token_ids = Some(vec![]);\n\n// after\nrequest.prompt_token_ids = Some(vec![1]);\n// or better: reject empty input client-side\nif tokens.is_empty() { return Err(\"empty prompt\"); }","handlingStrategy":"validation","validationCode":"if using_token_ids && prompt_token_ids.is_empty() {\n    return Err(\"prompt must contain at least one token\");\n}","typeGuard":"fn prompt_is_sendable(token_ids: &[u32]) -> bool {\n    !token_ids.is_empty()\n}","tryCatchPattern":"match result {\n    Err(e @ vllm_text::Error::EmptyPromptTokenIds { .. }) => {\n        respond_400(e); // client error: bad request body, not a server fault\n    }\n    other => other,\n}","preventionTips":["Reject empty prompts in client/gateway code before calling the API.","When chunking inputs, drop empty segments instead of forwarding them.","Treat this error as 400-class (is_request_validation_error() == true); do not retry it."],"tags":["request-validation","prompt","token-ids","api","rust","vllm"],"backgroundTag":null,"analyzedSha":"c794754062d49a8fdb63ab3c5215b488b865030c","analyzedAt":"2026-08-14T21:17:39.825Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}