sgl-project/sglang · error · ValueError

Invalid type for --lora-paths: {type(cfg.lora_paths)}. Expec

Error message

Invalid type for --lora-paths: {type(cfg.lora_paths)}. Expected a list or a dictionary.

What it means

Raised when --lora-paths is not a list, dict, or None. The argument accepts a JSON list of paths/dicts, a JSON dict mapping name->path, or nothing at all; any other JSON type (string, number, bool) is rejected.

Source

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

                    "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()
                    ],
                )
            elif cfg.lora_paths is None:
                self._late_resolution("check_lora_server_args", lora_paths=[])
            else:
                raise ValueError(
                    f"Invalid type for --lora-paths: {type(cfg.lora_paths)}. "
                    "Expected a list or a dictionary."
                )

            # Normalize target modules to a set; keep {"all"} as a sentinel
            # that gets resolved model-awarely in lora_manager.init_lora_shapes().
            if cfg.lora_target_modules:
                self._late_resolution(
                    "check_lora_server_args",
                    lora_target_modules=set(cfg.lora_target_modules),
                )
                if "all" in cfg.lora_target_modules:
                    assert (
                        len(cfg.lora_target_modules) == 1
                    ), "If 'all' is specified in --lora-target-modules, it should be the only module specified."

            # Ensure sufficient information is provided for LoRA initialization.
            assert cfg.lora_paths or (

View on GitHub (pinned to 0132848349)

Solutions

  1. Wrap the value as a JSON list: --lora-paths '["/path/to/lora"]'
  2. Or use a JSON dict: --lora-paths '{"name": "/path"}'
  3. Or omit --lora-paths entirely if no adapters are needed

Example fix

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

Strategy: type-guard

Validate before calling

assert isinstance(lora_paths, (list, dict, type(None))), f'bad --lora-paths type: {type(lora_paths)}'

Type guard

def is_lora_paths(v) -> bool:
    return v is None or isinstance(v, (list, dict))

Prevention

When it happens

Trigger: Passing --lora-paths '/path/to/lora' (a bare string) or a number instead of a JSON list/dict.

Common situations: Forgetting JSON quoting so the value parses as a scalar string instead of a collection; shell quoting mistakes that collapse the list.

Understand the failure class

Background: Invalid argument type errors: "must be of type string", "expected X, got Y", and ERR_INVALID_ARG_TYPE explained — this error's family across 15 libraries.

Related errors


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