BerriAI/litellm · error · HTTPException

Memory with key '{key}' not found

Error message

Memory with key '{key}' not found

What it means

HTTPException(404) from _find_memory_for_caller: no memory row with the requested key exists within the caller's visibility scope (own user_id/team_id). Used by get/update/delete paths to signal the entry does not exist for this caller.

Source

Thrown at litellm/proxy/memory/memory_endpoints.py:417

            skip=(page - 1) * page_size,
            take=page_size,
        )
    except Exception as e:
        raise _internal_error("Error listing memory: %s", e, "Internal error listing memory entries.")

    return MemoryListResponse(memories=[_row_to_model(r) for r in rows], total=total)


async def _find_memory_for_caller(
    prisma_client: "PrismaClient", key: str, user_api_key_dict: UserAPIKeyAuth
) -> _MemoryRecord:
    """Look up a memory row by key, scoped to the caller's visibility."""
    key_filter: Final[Mapping[str, object]] = {"key": key}
    vis: Final = _visibility_filter(user_api_key_dict)
    where: Final[Mapping[str, object]] = key_filter if vis is None else {"AND": [key_filter, vis]}
    rows = await _memory_table(prisma_client).find_many(where=where, take=1, order={"updated_at": "desc"})
    if not rows:
        raise HTTPException(status_code=404, detail=f"Memory with key '{key}' not found")
    return rows[0]


@router.get(
    "/v1/memory/{key:path}",
    tags=["memory management"],
    dependencies=[Depends(user_api_key_auth)],
    response_model=LiteLLM_MemoryRow,
)
async def get_memory(
    key: str,
    user_api_key_dict: UserAPIKeyAuth = Depends(user_api_key_auth),
):
    """Get a single memory entry by key, scoped to the caller."""
    prisma_client: Final = _require_prisma()
    row: Final = await _find_memory_for_caller(prisma_client, key, user_api_key_dict)
    return _row_to_model(row)

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Verify the memory key exists (list memory entries) before reading/updating/deleting it.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at litellm/proxy/memory/memory_endpoints.py:417 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/45531878015b744f. Report an issue: GitHub.