{"record":{"id":"570a00f14adfb2b5","repo":"sgl-project/sglang","slug":"prompt-text-file-not-found-path","errorCode":null,"errorMessage":"Prompt text file not found: {path}","messagePattern":"Prompt text file not found: (.+?)","errorType":"exception","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/entrypoints/diffusion_generator.py","lineNumber":485,"sourceCode":"            external_trace_header=external_trace_header,\n        )\n        output_batch = self._send_to_scheduler_and_wait_for_response(req)\n        if output_batch.error:\n            raise RuntimeError(output_batch.error)\n        if output_batch.output is None:\n            raise RuntimeError(\"action policy returned no output\")\n        return output_batch.output[0]\n\n    def _resolve_prompts(\n        self,\n        prompt: str | list[str] | None,\n        prompt_path: str | None = None,\n    ) -> list[str]:\n        \"\"\"Collect prompts from the argument or from a prompt file.\"\"\"\n        path = prompt_path or self.server_args.prompt_file_path\n        if path is not None:\n            if not os.path.exists(path):\n                raise FileNotFoundError(f\"Prompt text file not found: {path}\")\n            with open(path, encoding=\"utf-8\") as f:\n                prompts = [line.strip() for line in f if line.strip()]\n            if not prompts:\n                raise ValueError(f\"No prompts found in file: {path}\")\n            logger.info(\"Found %d prompts in %s\", len(prompts), path)\n            return prompts\n\n        if prompt is None:\n            return [\" \"]\n        if isinstance(prompt, str):\n            return [prompt]\n        return list(prompt)\n\n    def _log_summary(self, results: list[GenerationResult]) -> None:\n        if not results:\n            return\n        if self.server_args.warmup_mode != \"off\":\n            total_duration_ms = results[0].metrics.get(\"total_duration_ms\", 0)","sourceCodeStart":467,"sourceCodeEnd":503,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/entrypoints/diffusion_generator.py#L467-L503","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"# before\ngenerator.generate(prompt_path=\"prompts.txt\")\n# after\nfrom pathlib import Path\np = Path(\"prompts.txt\").resolve()\nassert p.exists(), f\"missing prompt file: {p}\"\ngenerator.generate(prompt_path=str(p))","handlingStrategy":"validation","validationCode":"import os\nif prompt_path and not os.path.exists(prompt_path):\n    raise SystemExit(f\"prompt file missing: {prompt_path}\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always resolve prompt paths to absolute paths at script start","Fail fast on missing input files before launching an expensive generation run"],"tags":["file-not-found","prompt-file","input-validation","filesystem"],"backgroundTag":"file-not-found","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}