{"record":{"id":"8ed1ec345da4f46f","repo":"vllm-project/vllm","slug":"failed-to-parse-chat-template-json","errorCode":null,"errorMessage":"failed to parse chat_template.json","messagePattern":"failed to parse chat_template\\.json","errorType":"exception","errorClass":"TemplateError","httpStatus":null,"severity":"error","filePath":"rust/src/chat/src/renderer/hf/error.rs","lineNumber":14,"sourceCode":"// SPDX-License-Identifier: Apache-2.0\n// SPDX-FileCopyrightText: Copyright contributors to the vLLM project\n\nuse thiserror::Error as ThisError;\n\n#[derive(Debug, ThisError)]\npub(crate) enum TemplateError {\n    #[error(\"failed to render jinja template\")]\n    Jinja(#[from] minijinja::Error),\n    #[error(\"failed to read chat template file\")]\n    ReadTemplateFile(#[source] std::io::Error),\n    #[error(\"chat template looks like a file path but does not exist\")]\n    MissingTemplatePath,\n    #[error(\"failed to parse chat_template.json\")]\n    ParseTemplateJson(#[source] serde_json::Error),\n    #[error(\"chat_template.json does not contain a valid template\")]\n    InvalidTemplateJson,\n}\n","sourceCodeStart":1,"sourceCodeEnd":19,"githubUrl":"https://github.com/vllm-project/vllm/blob/c794754062d49a8fdb63ab3c5215b488b865030c/rust/src/chat/src/renderer/hf/error.rs#L1-L19","documentation":"The HF renderer tried to deserialize `chat_template.json` (the multi-template file used by newer transformers models) and serde_json failed; the parse error is the `#[source]`. The file was found and read, but its bytes are not valid JSON.","triggerScenarios":"Pointing the renderer at a `chat_template.json` that is truncated, has trailing commas/comments, BOM issues, or was corrupted during download; a manually edited file with syntax mistakes.","commonSituations":"Interrupted `huggingface-cli download` leaving a partial file; hand-editing chat_template.json to add a template; files saved with UTF-8 BOM; symlinks to malformed content.","solutions":["Run `jq . chat_template.json` or `python -m json.tool` on the file to find the exact syntax error location.","Re-download the file from the model repo (`huggingface-cli download <repo> chat_template.json --force`).","Validate JSON in CI if you edit chat_template.json as part of your deploy pipeline."],"exampleFix":"# before\n$ python -m json.tool chat_template.json\n# Expecting ',' delimiter (fix the syntax error, or re-download)\n\n# after\n$ huggingface-cli download <model-repo> chat_template.json --local-dir . --force\n$ python -m json.tool chat_template.json  # OK","handlingStrategy":"validation","validationCode":"let raw = std::fs::read_to_string(\"chat_template.json\")?;\nlet parsed: serde_json::Value = serde_json::from_str(&raw)?; // fail fast on malformed JSON","typeGuard":null,"tryCatchPattern":"match result {\n    Err(TemplateError::ParseTemplateJson(err)) => {\n        eprintln!(\"chat_template.json is not valid JSON: {err}; re-download or fix syntax\");\n        std::process::exit(2);\n    }\n    other => other?,\n}","preventionTips":["Validate model artifacts with `python -m json.tool` after download.","Re-download on corruption instead of hand-patching partial files.","Add JSON validation for chat_template.json to your model-artifact CI."],"tags":["rust","json","chat-template","corruption","download"],"backgroundTag":null,"analyzedSha":"c794754062d49a8fdb63ab3c5215b488b865030c","analyzedAt":"2026-08-14T21:17:39.825Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}