sgl-project/sglang · error · FileNotFoundError
Prompt text file not found: {path}
Error message
Prompt text file not found: {path} What it means
DiffusionGenerator._resolve_prompts raises FileNotFoundError when the prompt file given via prompt_path (or the server-level --prompt-file-path) does not exist on disk. Prompts are read line-by-line from this file before any request is built.
Source
Thrown at python/sglang/multimodal_gen/runtime/entrypoints/diffusion_generator.py:485
external_trace_header=external_trace_header,
)
output_batch = self._send_to_scheduler_and_wait_for_response(req)
if output_batch.error:
raise RuntimeError(output_batch.error)
if output_batch.output is None:
raise RuntimeError("action policy returned no output")
return output_batch.output[0]
def _resolve_prompts(
self,
prompt: str | list[str] | None,
prompt_path: str | None = None,
) -> list[str]:
"""Collect prompts from the argument or from a prompt file."""
path = prompt_path or self.server_args.prompt_file_path
if path is not None:
if not os.path.exists(path):
raise FileNotFoundError(f"Prompt text file not found: {path}")
with open(path, encoding="utf-8") as f:
prompts = [line.strip() for line in f if line.strip()]
if not prompts:
raise ValueError(f"No prompts found in file: {path}")
logger.info("Found %d prompts in %s", len(prompts), path)
return prompts
if prompt is None:
return [" "]
if isinstance(prompt, str):
return [prompt]
return list(prompt)
def _log_summary(self, results: list[GenerationResult]) -> None:
if not results:
return
if self.server_args.warmup_mode != "off":
total_duration_ms = results[0].metrics.get("total_duration_ms", 0)View on GitHub (pinned to 0132848349)
Solutions
- Check the path exists: os.path.exists(path) before calling generate
- Use an absolute path for prompt_path / --prompt-file-path
- If running in Docker, verify the file is mounted into the container
- Fix typos or regenerate the prompt file
Example fix
# before
generator.generate(prompt_path="prompts.txt")
# after
from pathlib import Path
p = Path("prompts.txt").resolve()
assert p.exists(), f"missing prompt file: {p}"
generator.generate(prompt_path=str(p)) Defensive patterns
Strategy: validation
Validate before calling
import os
if prompt_path and not os.path.exists(prompt_path):
raise SystemExit(f"prompt file missing: {prompt_path}") Prevention
- Always resolve prompt paths to absolute paths at script start
- Fail fast on missing input files before launching an expensive generation run
When it happens
Trigger: Calling generate(prompt_path='prompts.txt') where prompts.txt is missing; launching with --prompt-file-path pointing to a wrong/relative path; running from a different working directory so a relative path no longer resolves.
Common situations: Relative paths resolved against the wrong CWD (client vs server process); typo in the filename; file not mounted into a container; path from config pointing to a removed file.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
- No prompts found in file: {path}
- Image path not found: {batch.image_path}
- metal shader source not found: {metal_src}
- unsupported input for causal Conv3D cat/pad CUDA
- unsupported input for usp_merge_heads CUDA
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/570a00f14adfb2b5.
Report an issue: GitHub.