{"record":{"id":"9c0a19a1513c881b","repo":"sgl-project/sglang","slug":"completion-template-completion-template-arg-is-n","errorCode":null,"errorMessage":"Completion template {completion_template_arg} is not a built-in template name or a valid completion template file path.","messagePattern":"Completion template (.+?) is not a built-in template name or a valid completion template file path\\.","errorType":"error_code","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/parser/template_manager.py","lineNumber":230,"sourceCode":"            model_path: Path to the model\n        \"\"\"\n        template_name = get_conv_template_by_model_path(model_path)\n        if template_name is not None:\n            logger.info(f\"Inferred chat template from model path: {template_name}\")\n            self._chat_template_name = template_name\n\n    def load_completion_template(self, completion_template_arg: str) -> None:\n        \"\"\"\n        Load completion template for code completion.\n\n        Args:\n            completion_template_arg: Template name or file path\n        \"\"\"\n        logger.info(f\"Loading completion template: {completion_template_arg}\")\n\n        if not completion_template_exists(completion_template_arg):\n            if not os.path.exists(completion_template_arg):\n                raise RuntimeError(\n                    f\"Completion template {completion_template_arg} is not a built-in template name \"\n                    \"or a valid completion template file path.\"\n                )\n\n            self._load_json_completion_template(completion_template_arg)\n        else:\n            self._completion_template_name = completion_template_arg\n\n        set_completion_template(self._completion_template_name)\n\n    def initialize_templates(\n        self,\n        tokenizer_manager: TokenizerManager,\n        model_path: str,\n        chat_template: Optional[str] = None,\n        completion_template: Optional[str] = None,\n    ) -> None:\n        \"\"\"","sourceCodeStart":212,"sourceCodeEnd":248,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/parser/template_manager.py#L212-L248","documentation":"Same pattern as the chat-template case but for --completion-template: load_completion_template accepts either a registered builtin completion template name or a file path; when the name isn't builtin and the path doesn't exist, it raises RuntimeError.","triggerScenarios":"Passing --completion-template base (not builtin) with no file named base in the working directory, or a JSON completion-template path that's mistyped or not mounted.","commonSituations":"Custom JSON completion template files not shipped in the Docker image, wrong relative path, or a builtin-name typo.","solutions":["Check builtin completion template names and use one exactly","Otherwise pass an absolute path to your JSON/jinja file and confirm it exists (ls)","Mount the file into the container or bake it into the image"],"exampleFix":"# before\npython -m sglang.launch_server --completion-template tmpl.json\n# after\npython -m sglang.launch_server --completion-template /app/templates/tmpl.json","handlingStrategy":"validation","validationCode":"import os\nok = completion_template_exists(arg) or os.path.isfile(os.path.abspath(arg))\nif not ok:\n    raise FileNotFoundError(arg)","typeGuard":"def is_loadable_completion_template(arg: str) -> TypeGuard[str]:\n    import os\n    from sglang.srt.parser.template_manager import completion_template_exists\n    return completion_template_exists(arg) or os.path.isfile(arg)","tryCatchPattern":"try:\n    tm.load_completion_template(completion_template_arg)\nexcept RuntimeError as e:\n    if \"Completion template\" in str(e):\n        sys.exit(f\"bad --completion-template: {completion_template_arg}\")\n    raise","preventionTips":["Pre-check os.path.isfile on absolute paths at startup","Keep custom completion templates next to code and reference absolutely","Smoke-test server args in CI with a template-existence assertion"],"tags":["completion-template","template-manager","file-not-found","server-args"],"backgroundTag":"template-file-not-found","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}