BerriAI/litellm · error · HTTPException

Request body must include at least one of: value, metadata.

Error message

Request body must include at least one of: value, metadata.

What it means

HTTPException raised on PUT of a memory entry when the request body contains neither 'value' nor 'metadata' (nothing in model_fields_set to write). The update would be a no-op, so the request is rejected as malformed instead of issuing an empty database write.

Source

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

    # is encoded as the JSON literal `null` instead — stored as Postgres
    # `jsonb 'null'`, which prisma deserializes back to Python `None` on
    # read. From a caller's perspective `PUT {"metadata": null}` clears
    # the field (subsequent reads return `metadata: null`), matching the
    # natural expectation. Callers wanting a strict SQL NULL must use
    # raw SQL — there is no typed-client path.
    #
    # When `metadata` is omitted from the request body entirely (not in
    # `model_fields_set`), the column is preserved as-is.
    fields_sent: Final = body.model_fields_set
    metadata_in_payload: Final = "metadata" in fields_sent

    data: Final[dict[str, object]] = {}
    if body.value is not None:
        data["value"] = body.value
    if metadata_in_payload:
        data["metadata"] = _serialize_metadata_for_prisma(body.metadata)
    if not data:
        raise HTTPException(
            status_code=400,
            detail="Request body must include at least one of: value, metadata.",
        )
    data["updated_by"] = user_api_key_dict.user_id

    async def _find_existing() -> _MemoryRecord | None:
        """Return the caller-visible row for `key`, or None."""
        try:
            return await _find_memory_for_caller(prisma_client, key, user_api_key_dict)
        except HTTPException as e:
            if e.status_code == 404:
                return None
            raise

    try:
        existing: Final = await _find_existing()
        if existing is not None:
            # Visibility != write authority. Make sure the caller actually

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Include at least one of 'value' or 'metadata' in the request body.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at litellm/proxy/memory/memory_endpoints.py:477 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/0fd78696e8e1bf99. Report an issue: GitHub.