{"record":{"id":"b2e65324afa20ea7","repo":"vllm-project/vllm","slug":"failed-to-build-structural-tag-message","errorCode":null,"errorMessage":"failed to build structural tag: {message}","messagePattern":"failed to build structural tag: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"rust/src/chat/src/error.rs","lineNumber":80,"sourceCode":"        #[source]\n        error: BoxedError,\n    },\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(\"chat request stream `{request_id}` closed before terminal output\")]\n    StreamClosedBeforeTerminalOutput { request_id: String },\n    #[error(\"tool call stream state is inconsistent: {message}\")]\n    ToolCallStreamInvariant { message: String },\n    #[error(\"duplicate tool name `{name}`\")]\n    DuplicateToolName { name: String },\n    #[error(\"tool_choice requires at least one available tool\")]\n    ToolChoiceRequiresTools,\n    #[error(\"tool_choice function `{name}` was not found in the available tools\")]\n    ToolChoiceFunctionNotFound { name: String },\n    #[error(\"failed to build structural tag: {message}\")]\n    StructuralTag { message: String },\n    #[error(transparent)]\n    Text(#[from] vllm_text::Error),\n    #[error(transparent)]\n    Tokenizer(#[from] vllm_tokenizer::TokenizerError),\n}\n\npub type Result<T> = std::result::Result<T, Error>;\n\nimpl Error {\n    /// Whether this error represents invalid user request parameters.\n    pub fn is_request_validation_error(&self) -> bool {\n        match self {\n            Self::PromptTooLong { .. }\n            | Self::DuplicateToolName { .. }\n            | Self::ToolChoiceRequiresTools\n            | Self::ToolChoiceFunctionNotFound { .. } => true,\n            Self::Text(error) => error.is_request_validation_error(),","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/vllm-project/vllm/blob/c794754062d49a8fdb63ab3c5215b488b865030c/rust/src/chat/src/error.rs#L62-L98","documentation":"Wraps failures from building a structural-tag guided-decoding grammar (`output/default/structural_tag.rs:53` maps the underlying error into this variant with a `message`). Structural tags combine triggers, JSON schemas, and output formats into a grammar; building that grammar can fail on invalid schemas, bad triggers, or grammar-compiler errors.","triggerScenarios":"Using the structural-tag output mode (OpenAI-style `structural_tag` / guided structural output) where the provided schema, trigger strings, or format specification cannot be compiled into a valid grammar by the guided-decoding backend.","commonSituations":"Malformed JSON schema inside the structural tag spec; empty or regex-invalid trigger patterns; mismatch between the schema and the format section (e.g. placeholders the format references that the schema does not define).","solutions":["Read `{message}` — it contains the underlying compiler error naming the offending field.","Validate each structural-tag component separately: triggers are non-empty valid strings, schema is valid JSON Schema, format placeholders match schema properties.","Simplify the structural tag to a minimal repro, then re-add components until the failure reappears.","If the grammar compiler is at fault, fall back to guided_json mode for the request."],"exampleFix":"// before\nStructuralTag {\n    schema: broken_schema, // missing \"type\"\n    triggers: vec![],\n    format: \"{answer}\",\n}\n\n// after\nStructuralTag {\n    schema: serde_json::from_str(VALID_SCHEMA)?, // checked Draft-07 schema with \"answer\"\n    triggers: vec![\"<answer>\".into()],\n    format: \"<answer>{answer}</answer>\",\n}","handlingStrategy":"validation","validationCode":"for tag in &structural_tags {\n    debug_assert!(!tag.triggers.is_empty(), \"structural tag needs a trigger\");\n    jsonschema::compile(&tag.schema)?; // fail fast on invalid schema\n}","typeGuard":null,"tryCatchPattern":"match result {\n    Err(vllm_chat::Error::StructuralTag { message }) => {\n        tracing::error!(%message, \"structural tag build failed\");\n        respond_bad_request(format!(\"invalid structural tag: {message}\"))\n    }\n    other => other?,\n}","preventionTips":["Validate each structural-tag component (triggers, schema, format placeholders) before enabling the mode.","Minimal-repro new tags in tests before shipping them to production traffic."],"tags":["rust","structural-tag","guided-decoding","grammar","validation"],"backgroundTag":null,"analyzedSha":"c794754062d49a8fdb63ab3c5215b488b865030c","analyzedAt":"2026-08-14T21:17:39.825Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}