sgl-project/sglang · error · ValueError

Config file not found: {file_path}

Error message

Config file not found: {file_path}

What it means

After suffix validation, the parser checks existence and raises if the path does not exist on disk. The error message embeds the exact path passed on the command line.

Source

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

            raise

        # Handle empty files or None content
        if config_data is None:
            config_data = {}

        if not isinstance(config_data, dict):
            raise ValueError("Config file must contain a dictionary at root level")

        return config_data

    def _validate_yaml_file(self, file_path: str) -> None:
        """Validate that the file is a YAML file."""
        path = Path(file_path)
        if path.suffix.lower() not in [".yaml", ".yml"]:
            raise ValueError(f"Config file must be YAML format, got: {path.suffix}")

        if not path.exists():
            raise ValueError(f"Config file not found: {file_path}")

    def _convert_config_to_args(self, config: Dict[str, Any]) -> List[str]:
        """Convert configuration dictionary to argument list."""
        args = []

        for key, value in config.items():
            key_norm = key.replace("-", "_")
            if key_norm in self.unsupported_actions:
                action = self.unsupported_actions[key_norm]
                msg = f"Unsupported config option '{key_norm}' with action '{action.__class__.__name__}'"
                raise ValueError(msg)
            if isinstance(value, bool):
                self._add_boolean_arg(args, key, value)
            elif isinstance(value, list):
                self._add_list_arg(args, key, value)
            elif isinstance(value, dict):
                self._add_scalar_arg(args, key, json.dumps(value))
            else:

View on GitHub (pinned to 0132848349)

Solutions

  1. Verify the path exists: ls -l <path> from the same working directory used to launch
  2. Use an absolute path for --config in containers/CI
  3. Fix typos or mount/copy the file into the environment

Example fix

# before
python -m sglang.launch_server --config confg.yaml
# after
python -m sglang.launch_server --config /etc/sglang/config.yaml
Defensive patterns

Strategy: validation

Validate before calling

from pathlib import Path
p = Path(cfg_path)
assert p.exists(), f"missing config: {p.resolve()}"

Prevention

When it happens

Trigger: --config pointing to a typo'd filename, a relative path resolved from a different working directory, or a file not mounted into a container.

Common situations: Relative paths inside Docker/Kubernetes where CWD differs from the host, or CI where the config artifact was not downloaded.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


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