{"record":{"id":"28797d8b7e2ae65b","repo":"sgl-project/sglang","slug":"load-function-expects-pkg-module-symbol-got-p","errorCode":null,"errorMessage":"_load_function expects 'pkg.module.symbol', got {path!r} (missing dotted prefix)","messagePattern":"_load_function expects 'pkg\\.module\\.symbol', got (.+?) \\(missing dotted prefix\\)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/debug_utils/dumper.py","lineNumber":1582,"sourceCode":"        s.connect((\"2001:4860:4860::8888\", 80))  # Doesn't need to be reachable\n        return s.getsockname()[0]\n    except Exception:\n        _log(\"Can not get local ip by remote\")\n    return None\n\n\ndef _load_function(path: str) -> Callable:\n    \"\"\"Resolve a fully-qualified Python path 'pkg.module.symbol' to its object.\n\n    Copied (verbatim, minus the function-registry branch) from\n    miles.utils.misc.load_function — kept inline so dumper.py has no\n    cross-package dependency.\n    \"\"\"\n    import importlib\n\n    module_path, _, attr = path.rpartition(\".\")\n    if not module_path:\n        raise ValueError(\n            f\"_load_function expects 'pkg.module.symbol', got {path!r} \"\n            f\"(missing dotted prefix)\"\n        )\n    module = importlib.import_module(module_path)\n    return getattr(module, attr)\n\n\ndef _init_custom_process_group(\n    *,\n    backend: str,\n    init_method: str,\n    world_size: int,\n    rank: int,\n    group_name: str,\n    timeout=None,\n):\n    \"\"\"Build a fresh torch.distributed process group, separate from the default\n    one and any other custom groups (e.g. RLHF weight-update groups). Used by","sourceCodeStart":1564,"sourceCodeEnd":1600,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/debug_utils/dumper.py#L1564-L1600","documentation":"Raised by the internal _load_function helper when the path argument has no dotted module prefix, i.e. rpartition('.') finds no '.' so module_path is empty. The helper requires a fully qualified 'pkg.module.symbol' string so it can importlib.import_module the module and getattr the symbol. A bare name like 'foo' cannot be resolved to any module.","triggerScenarios":"Calling _load_function('myfunc') or _load_function('') — any string without a dot. Typical when a debug/dump hook path is configured via SGLANG_DEBUG env vars or YAML config and the user gave just the function name instead of the full dotted path.","commonSituations":"Misconfigured debug hook paths in environment variables or patch YAML files; refactoring moved a function to a new module and someone shortened the path; copy-paste from docs that omitted the package prefix.","solutions":["Use the fully qualified path including package and module, e.g. 'sglang.srt.layers.mymodule.myfunc'","Verify the module imports cleanly in a REPL before configuring it (python -c \"import pkg.module\")","If loading from config, print/validate the path at config load time to catch typos early"],"exampleFix":"# before\n_load_function('capture_dump')\n\n# after\n_load_function('sglang.srt.debug_utils.hooks.capture_dump')","handlingStrategy":"validation","validationCode":"def is_valid_load_path(path: str) -> bool:\n    return bool(path) and '.' in path and path.rpartition('.')[0].isidentifier() is not None\n\nassert is_valid_load_path(path), f\"path must be 'pkg.module.symbol', got {path!r}\"","typeGuard":"def is_qualified_symbol_path(path: str) -> bool:\n    parts = path.split('.')\n    return len(parts) >= 2 and all(p.isidentifier() for p in parts) and not path.startswith('.') and not path.endswith('.')","tryCatchPattern":"try:\n    fn = _load_function(path)\nexcept ValueError:\n    raise ConfigError(f'hook path {path!r} must be pkg.module.symbol') from None","preventionTips":["Always write hook paths fully qualified including the package","Validate configured paths at startup, not at first use","Test that the module imports in the target environment"],"tags":["import","config-validation","debug-utils","sglang"],"backgroundTag":"invalid-module-path","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}