BerriAI/litellm · error · HTTPException

Mapping not found

Error message

Mapping not found

What it means

Error "Mapping not found" thrown in BerriAI/litellm.

Source

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

    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 update JWT key mappings")

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

    update_data: Final = data.model_dump(exclude_unset=True, exclude={"id", "key"})
    if data.key is not None:
        update_data["token"] = hash_token(data.key)
    update_data["updated_by"] = user_api_key_dict.user_id

    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 = f"jwt_key_mapping:{old_mapping.jwt_claim_name}:{old_mapping.jwt_claim_value}"
        await user_api_key_cache.async_delete_cache(cache_key)

        updated_mapping: Final = await JWTKeyMappingRepository(prisma_client).table.update(
            where={"id": data.id}, data=update_data
        )

        # Invalidate new cache key if claim fields changed
        cache_key = f"jwt_key_mapping:{updated_mapping.jwt_claim_name}:{updated_mapping.jwt_claim_value}"
        await user_api_key_cache.async_delete_cache(cache_key)

        return _to_response(updated_mapping)
    except HTTPException:
        raise
    except Exception as e:
        error_str: Final = str(e).lower()
        if "unique" in error_str or "p2002" in error_str:

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Verify the mapping ID exists by listing JWT key mappings first.
  2. Create the mapping before attempting to update or delete it.

When it happens

Trigger: Thrown at litellm/proxy/management_endpoints/jwt_key_mapping_endpoints.py:116 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/000af2ad790f87b5. Report an issue: GitHub.