{"record":{"id":"73da569a96aa9a16","repo":"BerriAI/litellm","slug":"wandb-project-id-must-be-set-for-weave-opentelemet","errorCode":null,"errorMessage":"WANDB_PROJECT_ID must be set for Weave OpenTelemetry integration. Format: <entity>/<project_name>","messagePattern":"WANDB_PROJECT_ID must be set for Weave OpenTelemetry integration\\. Format: <entity>/<project_name>","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/integrations/weave/weave_otel.py","lineNumber":142,"sourceCode":"        WANDB_API_KEY: Required. W&B API key for authentication.\n        WANDB_PROJECT_ID: Required. Project ID in format <entity>/<project_name>.\n        WANDB_HOST: Optional. Custom Weave host URL. Defaults to cloud endpoint.\n\n    Returns:\n        WeaveOtelConfig: A Pydantic model containing Weave OTEL configuration.\n\n    Raises:\n        ValueError: If required environment variables are missing.\n    \"\"\"\n    api_key: Final = os.getenv(\"WANDB_API_KEY\")\n    project_id: Final = os.getenv(\"WANDB_PROJECT_ID\")\n    host = os.getenv(\"WANDB_HOST\")\n\n    if not api_key:\n        raise ValueError(\"WANDB_API_KEY must be set for Weave OpenTelemetry integration.\")\n\n    if not project_id:\n        raise ValueError(\n            \"WANDB_PROJECT_ID must be set for Weave OpenTelemetry integration. Format: <entity>/<project_name>\"\n        )\n\n    if host:\n        if not host.startswith(\"http\"):\n            host = \"https://\" + host\n        # Self-managed instances use a different path\n        endpoint = host.rstrip(\"/\") + WEAVE_OTEL_ENDPOINT\n        verbose_logger.debug(\"Using Weave OTEL endpoint from host: %s\", endpoint)\n    else:\n        endpoint = WEAVE_BASE_URL + WEAVE_OTEL_ENDPOINT\n        verbose_logger.debug(\"Using Weave cloud endpoint: %s\", endpoint)\n\n    # Weave uses Basic auth with format: api:<WANDB_API_KEY>\n    auth_header: Final = _get_weave_authorization_header(api_key=api_key)\n    otlp_auth_headers: Final = f\"Authorization={auth_header},project_id={project_id}\"\n\n    # Set standard OTEL environment variables","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/integrations/weave/weave_otel.py#L124-L160","documentation":"Companion check to the WANDB_API_KEY guard: after the API key is validated, get_weave_otel_config requires WANDB_PROJECT_ID in the format <entity>/<project_name> so it can route traces to the right Weave project. Missing or malformed (non-slash) values raise this ValueError.","triggerScenarios":"WANDB_API_KEY is set but WANDB_PROJECT_ID is absent; the variable holds only a project name ('my-project') without the entity prefix; the var name is misspelled (WANDB_PROJECT vs WANDB_PROJECT_ID).","commonSituations":"Copy-pasting setup snippets that omit the entity; default-entity assumptions when the W&B entity differs from the username; deploying with only the API key secret configured.","solutions":["Set WANDB_PROJECT_ID to the full form: export WANDB_PROJECT_ID=\"<wandb-entity>/<project-name>\" (find the entity in your W&B URL: wandb.ai/<entity>/<project>)","Optionally set WANDB_HOST for self-managed W&B instances","Verify both vars before enabling the callback (see validation snippet)"],"exampleFix":"# before\nexport WANDB_API_KEY=...\nexport WANDB_PROJECT_ID=my-project  # missing entity -> ValueError\n\n# after\nexport WANDB_API_KEY=...\nexport WANDB_PROJECT_ID=my-team/my-project","handlingStrategy":"validation","validationCode":"import os\n\ndef valid_project_id(v: str | None) -> bool:\n    return bool(v) and \"/\" in v and len(v.split(\"/\")) == 2\n\nproject = os.getenv(\"WANDB_PROJECT_ID\")\nassert valid_project_id(project), \"WANDB_PROJECT_ID must be '<entity>/<project_name>'\"","typeGuard":"from typing import Any, TypeGuard\nimport re\n\n_WANDB_PROJECT = re.compile(r\"^[^/\\s]+/[^/\\s]+$\")\n\ndef is_wandb_project_id(v: Any) -> TypeGuard[str]:\n    return isinstance(v, str) and bool(_WANDB_PROJECT.match(v))","tryCatchPattern":"try:\n    cfg = get_weave_otel_config()\nexcept ValueError as e:\n    if \"WANDB_PROJECT_ID\" in str(e):\n        raise RuntimeError(\n            \"Set WANDB_PROJECT_ID='<entity>/<project>' (see your wandb.ai URL)\"\n        ) from e\n    raise","preventionTips":["Copy the entity/project pair directly from the wandb.ai URL to avoid prefix mistakes","Lint env config with a regex for WANDB_PROJECT_ID at deploy time","Keep the W&B variable trio (API key, project id, optional host) together in one secret block"],"tags":["weave","wandb","project-config","environment"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}