{"record":{"id":"4dbec41e7e898216","repo":"BerriAI/litellm","slug":"join-e-message-for-e-in-scope-errors","errorCode":null,"errorMessage":"\" | \".join(e.message for e in scope_errors)","messagePattern":"\" \\| \"\\.join\\(e\\.message for e in scope_errors\\)","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"litellm/proxy/policy_engine/policy_endpoints.py","lineNumber":784,"sourceCode":"        policy_names: Final = {p.policy_name for p in policies}\n        if request.policy_name not in policy_names:\n            raise HTTPException(\n                status_code=404,\n                detail=f\"Policy '{request.policy_name}' not found. Create the policy first.\",\n            )\n\n        # Reject concrete team/key/model scope entries that don't resolve to a real\n        # entity. Wildcard patterns are allowed through (they may match zero today).\n        scope_errors: Final = await PolicyValidator(\n            prisma_client=prisma_client, llm_router=llm_router\n        ).find_invalid_scope_entries(\n            policy_name=request.policy_name,\n            teams=request.teams,\n            keys=request.keys,\n            models=request.models,\n        )\n        if scope_errors:\n            raise HTTPException(status_code=400, detail=\" | \".join(e.message for e in scope_errors))\n\n        created_by: Final = user_api_key_dict.user_id\n        result: Final = await get_attachment_registry().add_attachment_to_db(\n            attachment_request=request,\n            prisma_client=prisma_client,\n            created_by=created_by,\n        )\n        return result\n    except HTTPException:\n        raise\n    except Exception as e:\n        verbose_proxy_logger.exception(\"Error creating policy attachment: %s\", e)\n        raise HTTPException(status_code=500, detail=str(e))\n\n\n@router.get(\n    \"/policies/attachments/{attachment_id}\",\n    tags=[\"Policies\"],","sourceCodeStart":766,"sourceCodeEnd":802,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/policy_engine/policy_endpoints.py#L766-L802","documentation":"Raised when PolicyValidator.find_invalid_scopes found concrete team/key/model entries in the attachment request that do not exist in the DB or router; the per-scope error messages are joined and returned.","triggerScenarios":"Thrown at litellm/proxy/policy_engine/policy_endpoints.py:784 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fix the listed scope errors: ensure referenced teams, keys, and models exist and are valid for the policy scope."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}