{"record":{"id":"2ca42d2671fd21c5","repo":"sgl-project/sglang","slug":"no-cargo-package-under-workspace-declares-pack","errorCode":null,"errorMessage":"no Cargo package under {workspace} declares `[package.metadata.sglang] python-module = \"{python_module}\"`; declared modules: {sorted(declared_modules)}","messagePattern":"no Cargo package under (.+?) declares `\\[package\\.metadata\\.sglang\\] python-module = \"(.+?)\"`; declared modules: (.+?)","errorType":"exception","errorClass":"ModuleNotFoundError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/rust_extensions/loader.py","lineNumber":192,"sourceCode":"        package_name = package.get(\"name\")\n        library = document.get(\"lib\", {}).get(\"name\")\n        if not package_name or not library:\n            raise ValueError(\n                f\"{manifest} declares python-module {python_module!r} but must \"\n                \"also set `package.name` and `lib.name`\"\n            )\n        matches.append(\n            _CrateSpec(\n                package=package_name,\n                library=library,\n                python_module=python_module,\n                workspace=workspace,\n                features=tuple(sglang_metadata.get(\"features\", ())),\n            )\n        )\n\n    if not matches:\n        raise ModuleNotFoundError(\n            f\"no Cargo package under {workspace} declares \"\n            f'`[package.metadata.sglang] python-module = \"{python_module}\"`; '\n            f\"declared modules: {sorted(declared_modules)}\",\n            name=python_module,\n        )\n    if len(matches) > 1:\n        raise ValueError(\n            f\"multiple Cargo packages under {workspace} declare python module \"\n            f\"{python_module!r}: {sorted(crate.package for crate in matches)}\"\n        )\n    return matches[0]\n\n\ndef _build_context(crate: _CrateSpec) -> _BuildContext:\n    source_digest = _source_digest(crate.workspace)\n    toolchain = {\n        \"cargo\": _command_version(\n            \"cargo\", \"--version\", \"--verbose\", cwd=crate.workspace","sourceCodeStart":174,"sourceCodeEnd":210,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/rust_extensions/loader.py#L174-L210","documentation":"No Cargo package in the workspace declares the requested Python module via `[package.metadata.sglang] python-module = \"...\"`. The message lists the modules that ARE declared to aid diagnosis.","triggerScenarios":"Calling load_rust_extension with a python_module string that no crate's sglang metadata declares (typo, module not yet registered).","commonSituations":"Renaming a Python module without updating Cargo metadata; adding a new extension without the metadata block; misspelling the dotted module name.","solutions":["Check the declared modules list in the message and fix the python_module spelling","Add a `[package.metadata.sglang] python-module = \"...\"` entry to the intended crate's Cargo.toml","Ensure the crate lives under the workspace being scanned"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"import tomllib, pathlib\ndeclared = set()\nfor p in pathlib.Path(ws).rglob(\"Cargo.toml\"):\n    d = tomllib.loads(p.read_text())\n    m = d.get(\"package\",{}).get(\"metadata\",{}).get(\"sglang\",{}).get(\"python-module\")\n    if m: declared.add(m)\nassert python_module in declared","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Register every new Rust-backed module in [package.metadata.sglang]","Keep a single source-of-truth list of python-module names"],"tags":["rust","discovery","module-not-found","metadata"],"backgroundTag":"module-registration-missing","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}