{"record":{"id":"ea205ccd528a7775","repo":"BerriAI/litellm","slug":"failed-to-update-jwt-key-mapping","errorCode":null,"errorMessage":"Failed to update JWT key mapping.","messagePattern":"Failed to update JWT key mapping\\.","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"litellm/proxy/management_endpoints/jwt_key_mapping_endpoints.py","lineNumber":144,"sourceCode":"        cache_key = f\"jwt_key_mapping:{updated_mapping.jwt_claim_name}:{updated_mapping.jwt_claim_value}\"\n        await user_api_key_cache.async_delete_cache(cache_key)\n\n        return _to_response(updated_mapping)\n    except HTTPException:\n        raise\n    except Exception as e:\n        error_str: Final = str(e).lower()\n        if \"unique\" in error_str or \"p2002\" in error_str:\n            raise HTTPException(\n                status_code=409,\n                detail=\"A mapping with those claim values already exists.\",\n            )\n        if \"foreign\" in error_str or \"p2003\" in error_str:\n            raise HTTPException(\n                status_code=400,\n                detail=\"The provided key does not match an existing virtual key.\",\n            )\n        raise HTTPException(status_code=500, detail=\"Failed to update JWT key mapping.\")\n\n\n@router.post(\"/jwt/key/mapping/delete\", tags=[\"JWT Key Mapping\"])\nasync def delete_jwt_key_mapping(\n    data: DeleteJWTKeyMappingRequest,\n    user_api_key_dict: UserAPIKeyAuth = Depends(user_api_key_auth),\n):\n    from litellm.proxy.proxy_server import prisma_client, user_api_key_cache\n\n    if user_api_key_dict.user_role != LitellmUserRoles.PROXY_ADMIN:\n        raise HTTPException(status_code=403, detail=\"Only proxy admins can delete JWT key mappings\")\n\n    if prisma_client is None:\n        raise HTTPException(status_code=500, detail=\"Database not connected\")\n\n    try:\n        # Get old mapping for cache invalidation\n        old_mapping: Final = await JWTKeyMappingRepository(prisma_client).table.find_unique(where={\"id\": data.id})","sourceCodeStart":126,"sourceCodeEnd":162,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/management_endpoints/jwt_key_mapping_endpoints.py#L126-L162","documentation":"Error \"Failed to update JWT key mapping.\" thrown in BerriAI/litellm.","triggerScenarios":"Thrown at litellm/proxy/management_endpoints/jwt_key_mapping_endpoints.py:144 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check proxy logs for the underlying database error.","Verify the mapping ID exists and the database connection is healthy, then retry."],"exampleFix":null,"handlingStrategy":null,"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"}