sgl-project/sglang · error · ValueError
Config file must be YAML format, got: {path.suffix}
Error message
Config file must be YAML format, got: {path.suffix} What it means
The config parser only accepts files with a .yaml or .yml suffix (case-insensitive) and rejects anything else before touching the file. This is a cheap guard so mispointed files fail loudly.
Source
Thrown at python/sglang/srt/utils/server_args_config_parser.py:136
config_data = yaml.safe_load(file)
except Exception as e:
logger.error(f"Failed to read config file {file_path}: {e}")
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)View on GitHub (pinned to 0132848349)
Solutions
- Rename or convert the file to .yaml/.yml
- If the file is JSON, convert it to YAML key:value mapping first
- Double-check the argument order — --config expects the config path, not the model path
Example fix
# before python -m sglang.launch_server --config settings.json # after python -m sglang.launch_server --config settings.yaml
Defensive patterns
Strategy: validation
Validate before calling
from pathlib import Path
assert Path(cfg).suffix.lower() in {".yaml", ".yml"}, "config must be .yaml/.yml" Prevention
- Standardize config file naming (.yaml)
- Separate model-path and config-path variables to avoid mixups
When it happens
Trigger: Passing --config server.json, --config config.txt, or any path whose Path.suffix is not .yaml/.yml.
Common situations: Renaming a JSON or template file to use with --config, or passing the model path instead of the config path by mistake.
Related errors
- Multiple config files specified! Only one allowed.
- Config file must contain a dictionary at root level
- Config file not found: {file_path}
- Unsupported config option '{key_norm}' with action '{action.
- {selection_error}{component_suffix}
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/fd57b628cb1a9881.
Report an issue: GitHub.