sgl-project/sglang · critical · RuntimeError
--sidecar requires module {module_name!r} to expose a callab
Error message
--sidecar requires module {module_name!r} to expose a callable main(argv). What it means
SGLang's sidecar launcher successfully imported the requested module but the `main` attribute it found is not callable. The sidecar protocol requires main(argv) as a function; anything else (a variable, class instance without __call__, None) triggers this error.
Source
Thrown at python/sglang/srt/entrypoints/sidecar.py:73
parsed, provider_args = parser.parse_known_args(args or [])
if parsed.sidecar_shutdown_timeout <= 0:
raise ValueError("--sidecar-shutdown-timeout must be greater than 0.")
return provider_args, parsed.sidecar_shutdown_timeout
def _run_sidecar(module_name: str, args: list[str], endpoint: str) -> None:
kill_itself_when_parent_died()
os.environ[SGLANG_GRPC_ENDPOINT_ENV] = endpoint
try:
main = getattr(importlib.import_module(module_name), "main")
except (AttributeError, ImportError) as e:
raise RuntimeError(
f"--sidecar requires importable module {module_name!r} "
"with a main(argv) function."
) from e
if not callable(main):
raise RuntimeError(
f"--sidecar requires module {module_name!r} to expose "
"a callable main(argv)."
)
main(args)
class Sidecar:
def __init__(
self,
proc,
module_name: str,
shutdown_timeout: float,
):
self.proc = proc
self.module_name = module_name
self.shutdown_timeout = shutdown_timeout
self._watchdog = SubprocessWatchdog(View on GitHub (pinned to 0132848349)
Solutions
- Define a plain function: def main(argv: list[str]) -> None (or a callable returning one)
- Check for accidental reassignment/shadowing of `main` in the module namespace
- If using a class, expose main = MyClass() where the instance implements __call__
Example fix
# before
main = SidecarRunner # class, not callable instance
# after
def main(argv):
SidecarRunner().run(argv) Defensive patterns
Strategy: validation
Validate before calling
import importlib
mod = importlib.import_module(module_name)
assert callable(getattr(mod, "main", None)), f"{module_name}.main must be callable" Type guard
def has_callable_main(mod) -> bool:
return callable(getattr(mod, "main", None)) Prevention
- Pin the sidecar entrypoint with a unit test asserting callable(module.main)
- Never rebind `main` to a non-function in sidecar modules
When it happens
Trigger: --sidecar module where module.main is assigned a non-callable value, e.g. `main = None`, `main = some_object`, or main was shadowed by an import.
Common situations: Refactoring a sidecar module and turning main into a variable, accidentally shadowing `main` with an import (`from x import main` where x.main is data), or writing a class without instantiating it as the entry point.
Related errors
- --sidecar requires importable module {module_name!r} with a
- SGLANG_RUST_SERVER is not supported with the offline Engine
- Multi-node weight cache daemons (nnodes > 1) require --dist-
- Weight cache daemon for pp_rank={pp_rank} tp_rank={tp_rank}
- Weight cache daemon (pid={p.pid}) exited prematurely with co
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/6cb22cc782589912.
Report an issue: GitHub.