sgl-project/sglang · error · ValueError

Multiple config files specified! Only one allowed.

Error message

Multiple config files specified! Only one allowed.

What it means

The --config flag accepts exactly one YAML file per server launch. _extract_config_file_path scans the raw argv for occurrences of the literal '--config' and raises if it finds more than one. This prevents ambiguous merging of multiple config files.

Source

Thrown at python/sglang/srt/utils/server_args_config_parser.py:90

        config_data = self._parse_yaml_config(config_file_path)
        config_args = self._convert_config_to_args(config_data)

        # Merge config args into CLI args
        config_index = cli_args.index("--config")

        # Split arguments around config file
        before_config = cli_args[:config_index]
        after_config = cli_args[config_index + 2 :]  # Skip --config and file path

        # Simple merge: config args + CLI args
        return config_args + before_config + after_config

    def _extract_config_file_path(self, args: List[str]) -> str:
        """Extract the config file path from arguments."""
        config_indices = [i for i, arg in enumerate(args) if arg == "--config"]

        if len(config_indices) > 1:
            raise ValueError("Multiple config files specified! Only one allowed.")

        if not config_indices:
            return None

        config_index = config_indices[0]
        if config_index == len(args) - 1:
            raise ValueError("No config file specified after --config flag!")

        return args[config_index + 1]

    def _parse_yaml_config(self, file_path: str) -> Dict[str, Any]:
        """
        Parse YAML configuration file and convert to argument list.

        Args:
            file_path: Path to the YAML configuration file

        Returns:

View on GitHub (pinned to 0132848349)

Solutions

  1. Merge the two YAML files into one before launching
  2. Move per-launch overrides from a second config into plain CLI flags (CLI args override config values)
  3. Check argv construction in wrapper scripts for duplicated --config

Example fix

# before
python -m sglang.launch_server --config base.yaml --config override.yaml
# after
python -m sglang.launch_server --config merged.yaml --model-path /new/path
Defensive patterns

Strategy: validation

Validate before calling

if args.count("--config") > 1:
    raise SystemExit("only one --config allowed; merge YAML files")

Prevention

When it happens

Trigger: Passing --config more than once on the command line, e.g. `--config a.yaml --config b.yaml`, or a wrapper script that appends --config to an argv that already contains it.

Common situations: Shell scripts that conditionally append --config, or copy-pasted launch commands combining a base config with an override config.

Related errors


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