{"record":{"id":"c38d3a812ddeabbd","repo":"vllm-project/vllm","slug":"failed-to-read-chat-template-file","errorCode":null,"errorMessage":"failed to read chat template file","messagePattern":"failed to read chat template file","errorType":"exception","errorClass":"TemplateError","httpStatus":null,"severity":"error","filePath":"rust/src/chat/src/renderer/hf/error.rs","lineNumber":10,"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 detected the configured chat template value is a filesystem path and tried to read it (`renderer/hf/template.rs:59`), but `fs::read_to_string` returned an I/O error (captured as `#[source]`). Distinct from error 33, which is thrown when the path does not exist at all — this wraps lower-level failures like permission denied or I/O faults.","triggerScenarios":"Setting `--chat-template /path/to/template.jinja` where the file exists but the server process lacks read permission, the path is a directory, or reading fails mid-way (disk/NFS error).","commonSituations":"Containerized vLLM running as non-root against a file owned by root with 0600; Kubernetes volume mount issues; trailing-slash paths pointing at directories; race where the file is deleted after the existence check.","solutions":["Check the chained `std::io::Error` kind: PermissionDenied → fix file ownership/permissions (chmod 644, chown the service user).","Confirm the path is a regular file and the full directory chain is traversable by the server user.","If on a network mount, verify the mount is healthy and re-deploy.","Prefer bundling the template inside the image/config rather than referencing host paths."],"exampleFix":"# before\nls -l /etc/vllm/template.jinja\n# -rw------- 1 root root ... ; server runs as vllm\n\n# after\nchown vllm:vllm /etc/vllm/template.jinja && chmod 644 /etc/vllm/template.jinja","handlingStrategy":"validation","validationCode":"let path = std::path::Path::new(&template_path);\nlet meta = std::fs::metadata(path)?;\nif !meta.is_file() { return Err(\"chat template path is not a regular file\"); }","typeGuard":null,"tryCatchPattern":"match result {\n    Err(TemplateError::ReadTemplateFile(io_err)) => {\n        eprintln!(\"cannot read chat template: {io_err}; check permissions and mount\");\n        std::process::exit(2);\n    }\n    other => other?,\n}","preventionTips":["Ship template files inside the container image at fixed absolute paths.","Verify the server user can read the file (run `sudo -u vllm cat <path>`) before launch.","Prefer config-embedded templates over host filesystem paths in orchestrated deployments."],"tags":["rust","io","chat-template","file-permissions","configuration"],"backgroundTag":null,"analyzedSha":"c794754062d49a8fdb63ab3c5215b488b865030c","analyzedAt":"2026-08-14T21:17:39.825Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}