{"record":{"id":"7f0601be10d51490","repo":"sgl-project/sglang","slug":"module-name-r-has-no-attribute-name-r-7f0601","errorCode":null,"errorMessage":"module {__name__!r} has no attribute {name!r}","messagePattern":"module (.+?) has no attribute (.+?)","errorType":"exception","errorClass":"AttributeError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/envs.py","lineNumber":410,"sourceCode":"# Special handling for boolean secondary var (TaylorSeer)\ndef _secondary_taylorseer_getter():\n    return get_bool_env_var(\n        \"SGLANG_CACHE_DIT_SECONDARY_TAYLORSEER\",\n        default=os.getenv(\"SGLANG_CACHE_DIT_TAYLORSEER\", \"false\"),\n    )\n\n\nenvironment_variables[\"SGLANG_CACHE_DIT_SECONDARY_TAYLORSEER\"] = (\n    _secondary_taylorseer_getter\n)\n\n\n# end-env-vars-definition\ndef __getattr__(name: str):\n    # lazy evaluation of environment variables\n    if name in environment_variables:\n        return environment_variables[name]()\n    raise AttributeError(f\"module {__name__!r} has no attribute {name!r}\")\n\n\ndef __dir__():\n    return list(environment_variables.keys())\n","sourceCodeStart":392,"sourceCodeEnd":415,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/envs.py#L392-L415","documentation":"envs.py uses a module-level __getattr__ for lazy evaluation of SGLANG_* environment variables. Accessing any attribute of sglang.multimodal_gen.envs that is not a key in environment_variables raises AttributeError instead of returning a lazy value.","triggerScenarios":"`from sglang.multimodal_gen import envs` then `envs.SOME_NAME` where SOME_NAME is not defined in the environment_variables dict (e.g. removed, renamed, or never-defined variable, or accessing a real module attribute like envs.os).","commonSituations":"Upgrading sglang where an env var was renamed/removed; typos in env var names; assuming every SGLANG_* string has a Python accessor; accessing non-env module attributes through this module.","solutions":["Check the environment_variables dict in python/sglang/multimodal_gen/envs.py for the exact accessor name","Read the value from os.environ directly if it's not exposed as a lazy accessor","Update to/from renamed accessors after version changes (consult the end-env-vars-definition section)"],"exampleFix":"# before\nvalue = envs.SGLANG_SOME_REMOVED_VAR  # AttributeError\n# after\nvalue = os.environ.get(\"SGLANG_SOME_REMOVED_VAR\", default)","handlingStrategy":"type-guard","validationCode":"from sglang.multimodal_gen import envs\nname = \"SGLANG_MY_VAR\"\nif name not in dir(envs):  # __dir__ lists environment_variables keys\n    value = os.environ.get(name)  # fallback to raw env\nelse:\n    value = getattr(envs, name)","typeGuard":"def env_or_raw(name: str, default=None):\n    try:\n        return getattr(envs, name)\n    except AttributeError:\n        return os.environ.get(name, default)","tryCatchPattern":"try:\n    val = getattr(envs, \"SGLANG_MY_VAR\")\nexcept AttributeError:\n    val = os.environ.get(\"SGLANG_MY_VAR\", default)","preventionTips":["Use dir(envs) to list valid accessors in your sglang version","Wrap env access with a helper providing defaults","Re-check accessor names after upgrading sglang"],"tags":["attribute-error","env-vars","lazy-loading","config"],"backgroundTag":"missing-env-var","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}