BerriAI/litellm · error · HTTPException

Only proxy admins can delete JWT key mappings

Error message

Only proxy admins can delete JWT key mappings

What it means

Error "Only proxy admins can delete JWT key mappings" thrown in BerriAI/litellm.

Source

Thrown at litellm/proxy/management_endpoints/jwt_key_mapping_endpoints.py:155

                detail="A mapping with those claim values already exists.",
            )
        if "foreign" in error_str or "p2003" in error_str:
            raise HTTPException(
                status_code=400,
                detail="The provided key does not match an existing virtual key.",
            )
        raise HTTPException(status_code=500, detail="Failed to update JWT key mapping.")


@router.post("/jwt/key/mapping/delete", tags=["JWT Key Mapping"])
async def delete_jwt_key_mapping(
    data: DeleteJWTKeyMappingRequest,
    user_api_key_dict: UserAPIKeyAuth = Depends(user_api_key_auth),
):
    from litellm.proxy.proxy_server import prisma_client, user_api_key_cache

    if user_api_key_dict.user_role != LitellmUserRoles.PROXY_ADMIN:
        raise HTTPException(status_code=403, detail="Only proxy admins can delete JWT key mappings")

    if prisma_client is None:
        raise HTTPException(status_code=500, detail="Database not connected")

    try:
        # Get old mapping for cache invalidation
        old_mapping: Final = await JWTKeyMappingRepository(prisma_client).table.find_unique(where={"id": data.id})

        if old_mapping is None:
            raise HTTPException(status_code=404, detail="Mapping not found")

        cache_key: Final = f"jwt_key_mapping:{old_mapping.jwt_claim_name}:{old_mapping.jwt_claim_value}"
        await user_api_key_cache.async_delete_cache(cache_key)

        await JWTKeyMappingRepository(prisma_client).table.delete(where={"id": data.id})
        return {"status": "success"}
    except HTTPException:
        raise

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Authenticate with a proxy admin API key.
  2. Ask a proxy admin to delete the JWT key mapping.

When it happens

Trigger: Thrown at litellm/proxy/management_endpoints/jwt_key_mapping_endpoints.py:155 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/4a876b09b2a24f6d. Report an issue: GitHub.