vllm-project/vllm · error · TemplateError

chat template looks like a file path but does not exist

Error message

chat template looks like a file path but does not exist

What it means

The configured chat-template value looks like a file path (heuristic in `renderer/hf/template.rs`), but no file exists at that path; template resolution ends with `Err(TemplateError::MissingTemplatePath)` at line 96. It means the renderer refused to fall back to treating the string as inline template text because it is path-shaped.

Source

Thrown at rust/src/chat/src/renderer/hf/error.rs:12

// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: Copyright contributors to the vLLM project

use thiserror::Error as ThisError;

#[derive(Debug, ThisError)]
pub(crate) enum TemplateError {
    #[error("failed to render jinja template")]
    Jinja(#[from] minijinja::Error),
    #[error("failed to read chat template file")]
    ReadTemplateFile(#[source] std::io::Error),
    #[error("chat template looks like a file path but does not exist")]
    MissingTemplatePath,
    #[error("failed to parse chat_template.json")]
    ParseTemplateJson(#[source] serde_json::Error),
    #[error("chat_template.json does not contain a valid template")]
    InvalidTemplateJson,
}

View on GitHub (pinned to c794754062)

Solutions

  1. Verify the file exists at the exact path the server resolves (check container CWD; use absolute paths).
  2. If the value was meant to be an inline template string, make sure it does not look like a path (contains no `/` and is not a lone filename) — or put it in a file instead.
  3. Add the template file to the Docker image / Kubernetes ConfigMap volume and re-run.

Example fix

# before
vllm serve model --chat-template ./custom.jinja # file not in container

# after
vllm serve model --chat-template /configs/custom.jinja # mounted at known absolute path
Defensive patterns

Strategy: validation

Validate before calling

let p = std::path::PathBuf::from(&cli.chat_template);
if p.as_os_str().to_string_lossy().contains('/') && !p.is_file() {
    return Err(format!("chat template path does not exist: {}", p.display()));
}

Try / catch

match result {
    Err(TemplateError::MissingTemplatePath) => {
        eprintln!("chat template path missing; use an absolute path mounted into the container");
        std::process::exit(2);
    }
    other => other?,
}

Prevention

When it happens

Trigger: `--chat-template ./templates/custom.jinja` where the file is missing relative to the server's working directory; absolute path typos; template file not shipped into the container image.

Common situations: Relative paths resolved against a different CWD inside Docker; CI/deploy omitting the template file from the artifact; host path not bind-mounted into the container.

Related errors


AI-assisted analysis of vllm-project/vllm@c794754062 (2026-08-14). Data as JSON: /api/errors/8a10bdaf9162d6a9. Report an issue: GitHub.