{"record":{"id":"ab8c42e2f970350d","repo":"sgl-project/sglang","slug":"no-prompts-found-in-file-path","errorCode":null,"errorMessage":"No prompts found in file: {path}","messagePattern":"No prompts found in file: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/entrypoints/diffusion_generator.py","lineNumber":489,"sourceCode":"            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)\n            logger.info(\n                f\"Warmed-up request processed in {GREEN}%.2f{RESET} seconds (with warmup excluded)\",\n                total_duration_ms / 1000.0,\n            )","sourceCodeStart":471,"sourceCodeEnd":507,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/entrypoints/diffusion_generator.py#L471-L507","documentation":"The prompt file given to DiffusionGenerator.generate exists and was opened successfully, but contains no non-blank lines after stripping, so no prompts could be extracted. Rather than sending an empty batch, the loader raises this ValueError.","triggerScenarios":"generate(prompt_path=...) where the file is empty, contains only whitespace/newlines, or only blank lines; a server launched with --prompt-file-path pointing at a truncated/placeholder file.","commonSituations":"Downstream step of a pipeline wrote an empty prompt file; encoding mismatch making every line unreadable; placeholder file committed by mistake; file truncated by a previous crash.","solutions":["Open the file and confirm it has at least one non-empty line","Regenerate the prompt file if it was truncated by an upstream step","Guard your pipeline: skip generation when the prompt file is empty","Check the file encoding is UTF-8 text and not, e.g., binary or UTF-16 read as one line"],"exampleFix":"# before\nopen(\"prompts.txt\",\"w\").close()  # accidentally empty\ngenerator.generate(prompt_path=\"prompts.txt\")\n# after\nwith open(\"prompts.txt\",\"w\") as f:\n    f.write(\"a red panda\\n\")\ngenerator.generate(prompt_path=\"prompts.txt\")","handlingStrategy":"validation","validationCode":"def load_prompts(path):\n    lines = [l.strip() for l in open(path, encoding=\"utf-8\") if l.strip()]\n    if not lines:\n        raise SystemExit(f\"prompt file {path} has no prompts\")\n    return lines","typeGuard":"def has_prompts(path) -> bool:\n    return any(l.strip() for l in open(path, encoding=\"utf-8\"))","tryCatchPattern":null,"preventionTips":["Validate prompt files at pipeline build time, not at generation time","Check upstream steps that write prompt files actually produced content"],"tags":["input-validation","prompt-file","empty-input"],"backgroundTag":"empty-input-file","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}