sgl-project/sglang · error · ValueError

Invalid type for item in --lora-paths list: {type(lora_path)

Error message

Invalid type for item in --lora-paths list: {type(lora_path)}. Expected a string or a dictionary.

What it means

Raised while parsing --lora-paths when a list item is neither a string nor a dict. Each list entry must be a plain adapter path string or a dict with lora_name/lora_path/pinned keys.

Source

Thrown at python/sglang/srt/server_args.py:10602

                                lora_id=LoRARef.deterministic_id(lora_path, lora_path),
                                lora_name=lora_path,
                                lora_path=lora_path,
                                pinned=False,
                            )
                    elif isinstance(lora_path, dict):
                        assert (
                            "lora_name" in lora_path and "lora_path" in lora_path
                        ), f"When providing LoRA paths as a list of dict, each dict should contain 'lora_name' and 'lora_path' keys. Got: {lora_path}"
                        lora_ref = LoRARef(
                            lora_id=LoRARef.deterministic_id(
                                lora_path["lora_name"], lora_path["lora_path"]
                            ),
                            lora_name=lora_path["lora_name"],
                            lora_path=lora_path["lora_path"],
                            pinned=lora_path.get("pinned", False),
                        )
                    else:
                        raise ValueError(
                            f"Invalid type for item in --lora-paths list: {type(lora_path)}. "
                            "Expected a string or a dictionary."
                        )
                    parsed_lora_paths.append(lora_ref)
                self._late_resolution(
                    "check_lora_server_args", lora_paths=parsed_lora_paths
                )
            elif isinstance(cfg.lora_paths, dict):
                self._late_resolution(
                    "check_lora_server_args",
                    lora_paths=[
                        LoRARef(
                            lora_id=LoRARef.deterministic_id(k, v),
                            lora_name=k,
                            lora_path=v,
                            pinned=False,
                        )
                        for k, v in cfg.lora_paths.items()

View on GitHub (pinned to 0132848349)

Solutions

  1. Make every list element a string path or an object {"lora_name": ..., "lora_path": ..., "pinned": bool}
  2. Validate the JSON with jq/python before launching the server

Example fix

# before
--lora-paths '["/models/lora-a", 123]'
# after
--lora-paths '["/models/lora-a", "/models/lora-b"]'
Defensive patterns

Strategy: type-guard

Validate before calling

def valid_lora_item(x):
    return isinstance(x, str) or (isinstance(x, dict) and isinstance(x.get('lora_name'), str) and isinstance(x.get('lora_path'), str))
assert all(valid_lora_item(i) for i in lora_paths_list)

Type guard

def is_lora_item(x) -> bool:
    return isinstance(x, (str, dict))

Prevention

When it happens

Trigger: Passing --lora-paths as a JSON list containing a number, boolean, nested list, or null element, e.g. '["/a", 42]'.

Common situations: Hand-written JSON on the command line with a typo, or a script that builds the list from unvalidated user input.

Related errors


AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28). Data as JSON: /api/errors/89c7e33db71873c6. Report an issue: GitHub.