{"record":{"id":"47c881a8e8ea7b63","repo":"chroma-core/chroma","slug":"the-requested-resource-could-not-be-found-input","errorCode":null,"errorMessage":"The requested resource could not be found: ${input}","messagePattern":"The requested resource could not be found: (.+?)","errorType":"http","errorClass":"ChromaNotFoundError","httpStatus":404,"severity":"error","filePath":"clients/js/packages/chromadb-core/src/ChromaFetch.ts","lineNumber":73,"sourceCode":"    const respBody = await clonedResp.json();\n    if (!clonedResp.ok) {\n      const error = createErrorByType(respBody?.error, respBody?.message);\n      if (error) {\n        throw error;\n      }\n      switch (resp.status) {\n        case 400:\n          throw new ChromaClientError(\n            `Bad request to ${input} with status: ${resp.statusText}`,\n          );\n        case 401:\n          throw new ChromaUnauthorizedError(`Unauthorized`);\n        case 403:\n          throw new ChromaForbiddenError(\n            `You do not have permission to access the requested resource.`,\n          );\n        case 404:\n          throw new ChromaNotFoundError(\n            `The requested resource could not be found: ${input}`,\n          );\n        case 409:\n          throw new ChromaUniqueError(\"The resource already exists\");\n        case 422:\n          if (\n            respBody?.message &&\n            (respBody?.message.startsWith(\"Quota exceeded\") ||\n              respBody?.message.startsWith(\"Billing limit exceeded\"))\n          ) {\n            throw new ChromaQuotaExceededError(respBody?.message);\n          }\n          break;\n        case 500:\n          throw parseServerError(respBody?.error);\n        case 502:\n        case 503:\n        case 504:","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/chroma-core/chroma/blob/aecdd12c8a891610db8653630b066b32ceb678b5/clients/js/packages/chromadb-core/src/ChromaFetch.ts#L55-L91","documentation":"_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.","triggerScenarios":"{\"$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.","commonSituations":"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'.","solutions":["Add an explicit positive integer k: {\"$min_k\": {\"keys\": [\"#score\"], \"k\": 3}}.","Use the exact field name 'k' — 'top', 'n', 'count', 'limit' are not recognized.","Ensure templated configs materialize a real integer for k; fail your config loader if the placeholder is empty rather than dropping the field.","Construct typed objects to avoid payload typos: MinK(keys=K.SCORE, k=3)."],"exampleFix":"// before\naggregate = {\"$max_k\": {\"keys\": [\"#score\"]}}  # ValueError: $max_k requires 'k' field\n\n# after\naggregate = {\"$max_k\": {\"keys\": [\"#score\"], \"k\": 5}}","handlingStrategy":"validation","validationCode":"def agg_has_k_field(payload: dict) -> bool:\n    op = next(iter(payload))\n    body = payload.get(op, {})\n    return isinstance(body, dict) and \"k\" in body","typeGuard":"def is_complete_k_aggregate(v: Any) -> TypeGuard[Dict[str, Dict[str, Any]]]:\n    if not (isinstance(v, dict) and len(v) == 1):\n        return False\n    op, body = next(iter(v.items()))\n    return op in {\"$min_k\", \"$max_k\"} and isinstance(body, dict) and \"keys\" in body and \"k\" in body","tryCatchPattern":"try:\n    Aggregate.from_dict(agg)\nexcept ValueError as e:\n    if \"requires 'k' field\" in str(e):\n        raise ValueError(\"group_by aggregate needs an explicit per-group count: \"\n                         \"{'$min_k': {'keys': ['#score'], 'k': n}}\") from e\n    raise","preventionTips":["k has no default — always write it explicitly as a positive int.","Treat unfilled k placeholders as config-load failures, not silently omitted fields.","Round-trip payloads through Aggregate.from_dict in tests to catch missing fields early."],"tags":["chromadb","aggregate","missing-field","valueerror","max-k","min-k"],"backgroundTag":"missing-required-field","analyzedSha":"aecdd12c8a891610db8653630b066b32ceb678b5","analyzedAt":"2026-08-16T21:53:27.228Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}