{"record":{"id":"bbaf17c708b38f76","repo":"sgl-project/sglang","slug":"sglang-grpc-worker-threads-cfg-grpc-worker-threa","errorCode":null,"errorMessage":"SGLANG_GRPC_WORKER_THREADS ({cfg.grpc_worker_threads}) must be >= 1","messagePattern":"SGLANG_GRPC_WORKER_THREADS \\((.+?)\\) must be >= 1","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/server_args.py","lineNumber":4505,"sourceCode":"            )\n\n        # Legacy SMG defaults its port to --port + 10000. Derive/validate only\n        # when gRPC is in use, so HTTP-only high ports don't fail validation.\n        legacy_grpc = cfg.smg_grpc_mode or cfg.grpc_mode\n        if legacy_grpc and cfg.grpc_port is None:\n            self._declare(\n                \"_handle_deprecated_args\",\n                grpc_port=cfg.port + 10000,\n            )\n\n        if cfg.grpc_port is not None:\n            if not (1 <= cfg.grpc_port <= 65535):\n                raise ValueError(\n                    \"--grpc-port / SGLANG_GRPC_PORT \"\n                    f\"({cfg.grpc_port}) must be between 1 and 65535\"\n                )\n            if cfg.grpc_worker_threads is not None and cfg.grpc_worker_threads < 1:\n                raise ValueError(\n                    \"SGLANG_GRPC_WORKER_THREADS \"\n                    f\"({cfg.grpc_worker_threads}) must be >= 1\"\n                )\n\n        # Native gRPC is incompatible with launch paths it doesn't wire into.\n        # Legacy takes precedence over grpc_port, keeping re-runs idempotent.\n        native_grpc = cfg.grpc_port is not None and not legacy_grpc\n        if cfg.sidecar_args is not None:\n            if cfg.sidecar is None:\n                raise ValueError(\"--sidecar-args requires --sidecar.\")\n            if not isinstance(cfg.sidecar_args, list) or not all(\n                isinstance(arg, str) for arg in cfg.sidecar_args\n            ):\n                raise ValueError(\"--sidecar-args must be a JSON array of strings.\")\n        if cfg.sidecar is not None:\n            if not cfg.sidecar.strip():\n                raise ValueError(\"--sidecar must not be empty.\")\n            if legacy_grpc:","sourceCodeStart":4487,"sourceCodeEnd":4523,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/server_args.py#L4487-L4523","documentation":"SGLang validates that the native gRPC worker-thread count (SGLANG_GRPC_WORKER_THREADS) is a positive integer. The check runs in ServerArgs config resolution when a gRPC port is configured, since a non-positive thread pool size is meaningless for the gRPC server.","triggerScenarios":"Setting env SGLANG_GRPC_WORKER_THREADS=0 or a negative number while also enabling native gRPC (--grpc-port / SGLANG_GRPC_PORT), then constructing or resolving ServerArgs.","commonSituations":"Env var typo (e.g. '0' as a placeholder), CI scripts exporting the var globally with a default of 0, or copy-pasted configs from deployments that disabled gRPC workers.","solutions":["Set SGLANG_GRPC_WORKER_THREADS to a positive integer (e.g. 1 or 8), or unset it to use the default","If gRPC is not wanted, unset SGLANG_GRPC_PORT / remove --grpc-port so this validation block is skipped","Check shell profile / CI secrets for a stale SGLANG_GRPC_WORKER_THREADS export"],"exampleFix":"# before\nexport SGLANG_GRPC_WORKER_THREADS=0\n# after\nexport SGLANG_GRPC_WORKER_THREADS=8","handlingStrategy":"validation","validationCode":"import os\nthreads = int(os.environ.get(\"SGLANG_GRPC_WORKER_THREADS\", \"0\") or 0)\ngrpc_port = os.environ.get(\"SGLANG_GRPC_PORT\")\nif grpc_port and threads < 1:\n    os.environ[\"SGLANG_GRPC_WORKER_THREADS\"] = str(max(threads, 8))","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never use 0 as a placeholder for SGLANG_GRPC_WORKER_THREADS; unset it instead","Add a config lint step that checks numeric env vars against their documented minimums before launch"],"tags":["grpc","config-validation","environment-variable","server-args"],"backgroundTag":"invalid-environment-variable","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}