vllm-project/vllm · error · TypeError

tenant_id must be a string or null, got {type(value).__name_

Error message

tenant_id must be a string or null, got {type(value).__name__}: {value!r}

What it means

_normalize_tenant_id only accepts string or null for the config file's tenant_id field (whitespace-only strings fall back to the default tenant). Any other JSON type — number, boolean, list, object — raises TypeError with the offending type name, because the tenant id is forwarded verbatim to the mooncake store as an isolation key.

Source

Thrown at vllm/distributed/kv_transfer/kv_connector/v1/mooncake/store/worker.py:184

            enable_offload=bool(config.get("enable_offload", False)),
            tenant_id=_normalize_tenant_id(config.get("tenant_id", DEFAULT_TENANT_ID)),
        )

    @staticmethod
    def load_from_config() -> "MooncakeStoreConfig":
        config_path = os.getenv("MOONCAKE_CONFIG_PATH")
        if not config_path:
            raise ValueError(
                "The environment variable 'MOONCAKE_CONFIG_PATH' is not set."
            )
        return MooncakeStoreConfig.from_file(config_path)


def _normalize_tenant_id(value: Any) -> str:
    if value is None:
        return DEFAULT_TENANT_ID
    if not isinstance(value, str):
        raise TypeError(
            f"tenant_id must be a string or null, got {type(value).__name__}: {value!r}"
        )
    tenant_id = value.strip()
    return tenant_id if tenant_id else DEFAULT_TENANT_ID


def _parse_size(value: Any) -> int:
    """Parse storage size strings with units: GB, MB, KB, B."""
    if isinstance(value, int):
        return value
    if not isinstance(value, str):
        try:
            return int(value)
        except (TypeError, ValueError) as e:
            raise TypeError(f"Unsupported type for size: {type(value)}") from e

    cleaned = value.strip().lower()
    if not cleaned:

View on GitHub (pinned to c794754062)

Solutions

  1. Quote the tenant id: "tenant_id": "tenant-123"
  2. Set it to null (or omit the key) to use the default tenant

Example fix

// before
{ "tenant_id": 12345 }

// after
{ "tenant_id": "12345" }
Defensive patterns

Strategy: type-guard

Validate before calling

tid = raw.get("tenant_id")
if tid is not None and not isinstance(tid, str):
    raise TypeError("tenant_id must be a string or null")

Type guard

def is_valid_tenant_id(v) -> bool:
    return v is None or isinstance(v, str)

Prevention

When it happens

Trigger: "tenant_id": 123, true, or ["a"] in the mooncake config JSON.

Common situations: Numeric tenant ids from orchestration systems templated into the JSON without quoting; YAML->JSON conversion turning a quoted id into a bare number.

Related errors


AI-assisted analysis of vllm-project/vllm@c794754062 (2026-08-14). Data as JSON: /api/errors/edf758b24d97c514. Report an issue: GitHub.