chroma-core/chroma · error · ChromaNotFoundError

The requested resource could not be found: ${input}

Error message

The requested resource could not be found: ${input}

What it means

_parse_k_aggregate() (operator.py:1360-1361) raises ValueError when a '$min_k'/'$max_k' aggregation dict lacks the 'k' field. 'k' sets how many records the aggregation keeps per group (MinK keeps the k smallest-ranked, MaxK the k largest), and it has no default, so the payload {"keys": [...]} alone cannot define a grouping result. The parser checks 'keys' first (operator.py:1358), so this specific error means keys was present but k was not.

Source

Thrown at clients/js/packages/chromadb-core/src/ChromaFetch.ts:73

    const respBody = await clonedResp.json();
    if (!clonedResp.ok) {
      const error = createErrorByType(respBody?.error, respBody?.message);
      if (error) {
        throw error;
      }
      switch (resp.status) {
        case 400:
          throw new ChromaClientError(
            `Bad request to ${input} with status: ${resp.statusText}`,
          );
        case 401:
          throw new ChromaUnauthorizedError(`Unauthorized`);
        case 403:
          throw new ChromaForbiddenError(
            `You do not have permission to access the requested resource.`,
          );
        case 404:
          throw new ChromaNotFoundError(
            `The requested resource could not be found: ${input}`,
          );
        case 409:
          throw new ChromaUniqueError("The resource already exists");
        case 422:
          if (
            respBody?.message &&
            (respBody?.message.startsWith("Quota exceeded") ||
              respBody?.message.startsWith("Billing limit exceeded"))
          ) {
            throw new ChromaQuotaExceededError(respBody?.message);
          }
          break;
        case 500:
          throw parseServerError(respBody?.error);
        case 502:
        case 503:
        case 504:

View on GitHub (pinned to aecdd12c8a)

Solutions

  1. Add an explicit positive integer k: {"$min_k": {"keys": ["#score"], "k": 3}}.
  2. Use the exact field name 'k' — 'top', 'n', 'count', 'limit' are not recognized.
  3. Ensure templated configs materialize a real integer for k; fail your config loader if the placeholder is empty rather than dropping the field.
  4. Construct typed objects to avoid payload typos: MinK(keys=K.SCORE, k=3).

Example fix

// before
aggregate = {"$max_k": {"keys": ["#score"]}}  # ValueError: $max_k requires 'k' field

# after
aggregate = {"$max_k": {"keys": ["#score"], "k": 5}}
Defensive patterns

Strategy: validation

Validate before calling

def agg_has_k_field(payload: dict) -> bool:
    op = next(iter(payload))
    body = payload.get(op, {})
    return isinstance(body, dict) and "k" in body

Type guard

def is_complete_k_aggregate(v: Any) -> TypeGuard[Dict[str, Dict[str, Any]]]:
    if not (isinstance(v, dict) and len(v) == 1):
        return False
    op, body = next(iter(v.items()))
    return op in {"$min_k", "$max_k"} and isinstance(body, dict) and "keys" in body and "k" in body

Try / catch

try:
    Aggregate.from_dict(agg)
except ValueError as e:
    if "requires 'k' field" in str(e):
        raise ValueError("group_by aggregate needs an explicit per-group count: "
                         "{'$min_k': {'keys': ['#score'], 'k': n}}") from e
    raise

Prevention

When it happens

Trigger: {"$max_k": {"keys": ["#score"]}} — no k; 'k' misspelled as 'top', 'count', 'limit', or 'n' in config; a programmatic builder that only sets keys; template placeholders for k left unfilled so the field is dropped from the JSON.

Common situations: Assuming group_by implies 'top 1' or some default k; YAML omitting the k line during refactor; config generators that skip fields whose variables are undefined; copying an aggregate example and deleting k to 'use the default'.

Related errors


AI-assisted analysis of chroma-core/chroma@aecdd12c8a (2026-08-16). Data as JSON: /api/errors/47c881a8e8ea7b63. Report an issue: GitHub.