Skip to content

[Bug] Router crashes on startup if --worker-urls is not provided #8148

@amenacruz

Description

@amenacruz

Checklist

  • 1. I have searched related issues but cannot get the expected help.
  • 2. The bug has not been fixed in the latest version.
  • 3. Please note that if the bug-related issue you submitted lacks corresponding environment info and a minimal reproducible demo, it will be challenging for us to reproduce and resolve the issue, reducing the likelihood of receiving feedback.
  • 4. If the issue you raised is not a bug but a question, please raise a discussion at https://github.com/sgl-project/sglang/discussions/new/choose Otherwise, it will be closed.
  • 5. Please use English, otherwise it will be closed.

Describe the bug

The SGLang router fails to start if it is launched without the --worker-urls command-line argument. This prevents the router from being initialized without a predefined set of workers, which is a valid use case (e.g., when workers will be registered dynamically).

The error was introduced on this commit: 09ae5b2

File: sgl-router/py_src/sglang_router/launch_router.py:208

Proposed solution:
The issue can be resolved by modifying RouterArgs.add_cli_args in sglang/sgl-router/py_src/sglang_router/launch_router.py to ensure --worker-urls defaults to an empty list.

# In RouterArgs.add_cli_args:
parser.add_argument(
    "--worker-urls",
    type=str,
    nargs="*",  # Allow zero or more arguments
    default=[], # Default to an empty list
    help="List of worker URLs (e.g., http://worker1:8000 http://worker2:8000)",
)```

### Reproduction

1. Run the router launcher from the command line without providing any worker URLs.

`python -m sglang_router.launch_router --port 30000 --host 0.0.0.0 --policy random`

The router crashes with a TypeError because the underlying Rust component receives None instead of a list for the worker_urls parameter.

Error starting router: argument 'worker_urls': 'NoneType' object cannot be converted to 'Sequence'
Traceback (most recent call last):
File ".../sglang_router/launch_router.py", line 473, in main
launch_router(router_args)
File ".../sglang_router/launch_router.py", line 392, in launch_router
router = Router(...)
File ".../sglang_router/router.py", line 90, in init
self._router = _Router(...)
TypeError: argument 'worker_urls': 'NoneType' object cannot be converted to 'Sequence'


### Environment

This is an error on the launch script on version 0.1.5. 

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions