sgl-project/sglang · error · ValueError

Config file not found: {args.config}

Error message

Config file not found: {args.config}

What it means

Raised by the `serve` CLI command's validate() when --config is given but the file does not exist (os.path.exists returns False). Identical guard to the generate command's, applied before the serve command starts a server.

Source

Thrown at python/sglang/multimodal_gen/runtime/entrypoints/cli/serve.py:60

        run_sgl_diffusion_webui(server_args)


class ServeSubcommand(CLISubcommand):
    """The `serve` subcommand for the sglang-diffusion CLI"""

    def __init__(self) -> None:
        self.name = "serve"
        super().__init__()

    def cmd(
        self, args: argparse.Namespace, unknown_args: list[str] | None = None
    ) -> None:
        execute_serve_cmd(args, unknown_args)

    def validate(self, args: argparse.Namespace) -> None:
        """Validate the arguments for this command"""
        if args.config and not os.path.exists(args.config):
            raise ValueError(f"Config file not found: {args.config}")

    def subparser_init(
        self, subparsers: argparse._SubParsersAction
    ) -> FlexibleArgumentParser:
        serve_parser = subparsers.add_parser(
            "serve",
            help="Launch the server and start FastAPI listener.",
            usage="sglang serve --model-path MODEL_PATH_OR_ID [OPTIONS]",
        )

        serve_parser = add_multimodal_gen_serve_args(serve_parser)

        return cast(FlexibleArgumentParser, serve_parser)


def cmd_init() -> list[CLISubcommand]:
    return [ServeSubcommand()]

View on GitHub (pinned to 0132848349)

Solutions

  1. Check the exact path with ls / abspath before launching
  2. Use absolute paths in service/docker definitions
  3. Ensure the config file is included in the container image or volume mount
Defensive patterns

Strategy: validation

Validate before calling

import os
if args.config and not os.path.isfile(os.path.abspath(args.config)):
    raise SystemExit(f"config not found: {args.config}")

Prevention

When it happens

Trigger: Running `sglang serve --config missing.yaml` where the config path is wrong, relative to the wrong cwd, or not mounted in the deployment environment.

Common situations: Deploying with docker/k8s where the config wasn't mounted at the expected path, relative paths breaking when launched from systemd or another directory, typos.

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/8c13bbdd00386907. Report an issue: GitHub.