{"record":{"id":"6c9aa7f1ecfdaf94","repo":"sgl-project/sglang","slug":"either-the-environment-variable-mooncake-master","errorCode":null,"errorMessage":"Either the environment variable 'MOONCAKE_MASTER' or 'MOONCAKE_CLIENT' is not set.","messagePattern":"Either the environment variable 'MOONCAKE_MASTER' or 'MOONCAKE_CLIENT' is not set\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/mem_cache/storage/mooncake_store/mooncake_store.py","lineNumber":179,"sourceCode":"            ssd_offload_path=config.get(\n                \"ssd_offload_path\", envs.MOONCAKE_OFFLOAD_FILE_STORAGE_PATH.default\n            ),\n            tenant_id=_normalize_tenant_id(\n                config.get(\"tenant_id\", envs.MOONCAKE_TENANT_ID.default)\n            ),\n        )\n\n    @staticmethod\n    def load_from_env() -> \"MooncakeStoreConfig\":\n        \"\"\"Load config from a file specified in the environment variable.\n        export MOONCAKE_MASTER=10.13.3.232:50051\n        export MOONCAKE_PROTOCOL=\"rdma\"\n        export MOONCAKE_DEVICE=\"\"\n        export MOONCAKE_TE_META_DATA_SERVER=\"P2PHANDSHAKE\"\n        \"\"\"\n        # other required environment variables...\n        if not envs.MOONCAKE_MASTER.is_set() and not envs.MOONCAKE_CLIENT.is_set():\n            raise ValueError(\n                \"Either the environment variable 'MOONCAKE_MASTER' or 'MOONCAKE_CLIENT' is not set.\"\n            )\n\n        # Special handling for local_hostname: try MOONCAKE_LOCAL_HOSTNAME first,\n        # then fall back to LOCAL_HOSTNAME if not set.\n        # This is for forward compatibility with the legacy LOCAL_HOSTNAME environment variable.\n        if envs.MOONCAKE_LOCAL_HOSTNAME.is_set():\n            local_hostname = envs.MOONCAKE_LOCAL_HOSTNAME.get()\n        else:\n            local_hostname = os.getenv(\n                \"LOCAL_HOSTNAME\", envs.MOONCAKE_LOCAL_HOSTNAME.default\n            )\n\n        return MooncakeStoreConfig(\n            local_hostname=local_hostname,\n            metadata_server=envs.MOONCAKE_TE_META_DATA_SERVER.get(),\n            global_segment_size=_parse_global_segment_size(\n                envs.MOONCAKE_GLOBAL_SEGMENT_SIZE.get()","sourceCodeStart":161,"sourceCodeEnd":197,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/mem_cache/storage/mooncake_store/mooncake_store.py#L161-L197","documentation":"Env-based Mooncake config loading requires MOONCAKE_MASTER or MOONCAKE_CLIENT to identify the metadata service; neither is set, so load_from_env() raises ValueError. The docstring above it shows the full expected env set (MOONCAKE_PROTOCOL, MOONCAKE_DEVICE, MOONCAKE_TE_META_DATA_SERVER, ...).","triggerScenarios":"Config source resolves to env (no config file, no extra_config) while both MOONCAKE_MASTER and MOONCAKE_CLIENT are unset in the process environment.","commonSituations":"Launching SGLang with mooncake backend in a fresh shell/CI pod without sourcing the mooncake env script; env vars set only on the master node, not workers.","solutions":["export MOONCAKE_MASTER=<ip:port> (or MOONCAKE_CLIENT) plus the documented MOONCAKE_* vars","Or provide the JSON config file / extra_config so env loading is skipped"],"exampleFix":"# before\npython -m sglang.launch_server --hicache-storage-backend mooncake  # no env\n# after\nexport MOONCAKE_MASTER=10.0.0.2:50051\nexport MOONCAKE_TRANSFER_ENGINE=rdma\npython -m sglang.launch_server --hicache-storage-backend mooncake","handlingStrategy":"validation","validationCode":"import os\nassert os.environ.get('MOONCAKE_MASTER') or os.environ.get('MOONCAKE_CLIENT'), \\\n    'set MOONCAKE_MASTER=<ip:port> (or MOONCAKE_CLIENT) before launching SGLang with mooncake'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Centralize mooncake env setup in one sourced script/manifest","Add a preflight env check to launch wrappers"],"tags":["env-var","mooncake","missing-configuration"],"backgroundTag":"missing-env-var","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}