{"record":{"id":"7ceb867291fa3acd","repo":"sgl-project/sglang","slug":"invalid-backend-value-must-be-one-of-jo","errorCode":null,"errorMessage":"Invalid backend: {value}. Must be one of: {', '.join([m.value for m in cls])}","messagePattern":"Invalid backend: (.+?)\\. Must be one of: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/server_args/server_args.py","lineNumber":131,"sourceCode":"class Backend(str, Enum):\n    \"\"\"\n    Enumeration for different model backends.\n    - AUTO: Automatically select backend (prefer sglang native, fallback to diffusers)\n    - SGLANG: Use sglang's native optimized implementation\n    - DIFFUSERS: Use vanilla diffusers pipeline (supports all diffusers models)\n    \"\"\"\n\n    AUTO = \"auto\"\n    SGLANG = \"sglang\"\n    DIFFUSERS = \"diffusers\"\n\n    @classmethod\n    def from_string(cls, value: str) -> \"Backend\":\n        \"\"\"Convert string to Backend enum.\"\"\"\n        try:\n            return cls(value.lower())\n        except ValueError:\n            raise ValueError(\n                f\"Invalid backend: {value}. Must be one of: {', '.join([m.value for m in cls])}\"\n            ) from None\n\n    @classmethod\n    def choices(cls) -> list[str]:\n        \"\"\"Get all available choices as strings for argparse.\"\"\"\n        return [backend.value for backend in cls]\n\n\nWARMUP_MODES = (\"off\", \"request\", \"server\")\n\n# Default prompt sequence-length buckets for breakable CUDA graph (BCG) padding.\n# Prompt-conditioning is padded up to the smallest bucket that fits so prompts\n# of different lengths share one captured graph.\nDEFAULT_BCG_TEXT_BUCKETS = (64, 128, 256, 512, 1024)\n\nBREAKABLE_CUDA_GRAPH_SUPPORTED_MODEL_IDS = frozenset(\n    {","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/server_args/server_args.py#L113-L149","documentation":"Raised by Backend.from_string when the string passed cannot be matched to a Backend enum member. The lookup is cls(value.lower()), so any string that is not exactly (case-insensitively) one of the enum's values fails. The message lists all valid values.","triggerScenarios":"Calling from_string('tensorrt') when no such enum member exists; passing a backend name with a typo, trailing whitespace, or a value not defined on the Backend enum. Callers include derive_pool_result_endpoint, Backend.__post_init__, and from_kwargs.","commonSituations":"CLI/config typos in --backend style flags, copying a backend name from another project (e.g. 'trt', 'nccl'), version changes where a backend value was renamed or removed.","solutions":["Fix the string to exactly match one of the values printed in the error message","Check the enum definition next to from_string in server_args.py for the authoritative list of valid values","If loading from config/env, strip whitespace and normalize case before calling from_string"],"exampleFix":"# before\nBackend.from_string(\"flashinde \")\n# after\nBackend.from_string(\"flashinfer\")","handlingStrategy":"validation","validationCode":"from sglang.multimodal_gen.runtime.server_args.server_args import Backend\nvalid = {m.value for m in Backend}\nif value.lower() not in valid:\n    raise SystemExit(f\"unsupported backend {value!r}; choose from {sorted(valid)}\")\nbackend = Backend.from_string(value)","typeGuard":"def is_valid_backend(value: str) -> bool:\n    return isinstance(value, str) and value.lower() in {m.value for m in Backend}","tryCatchPattern":null,"preventionTips":["Validate backend strings against Backend values before constructing ServerArgs","Centralize backend name constants instead of scattering literals"],"tags":["config","enum-validation","backend-selection"],"backgroundTag":"invalid-enum-value","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}