{"record":{"id":"67698ea5fbce87cb","repo":"chroma-core/chroma","slug":"no-api-key-provided","errorCode":null,"errorMessage":"No API key provided","messagePattern":"No API key provided","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"clients/js/packages/chromadb-core/src/CloudClient.ts","lineNumber":28,"sourceCode":"  tenant?: string;\n  cloudHost?: string;\n  cloudPort?: string;\n}\n\nclass CloudClient extends ChromaClient {\n  constructor({\n    apiKey,\n    database,\n    tenant,\n    cloudHost,\n    cloudPort,\n  }: CloudClientParams) {\n    // If no API key is provided, try to load it from the environment variable\n    if (!apiKey) {\n      apiKey = process.env.CHROMA_API_KEY;\n    }\n    if (!apiKey) {\n      throw new Error(\"No API key provided\");\n    }\n\n    cloudHost = cloudHost || \"https://api.trychroma.com\";\n    cloudPort = cloudPort || \"8000\";\n\n    const path = `${cloudHost}:${cloudPort}`;\n\n    const auth: AuthOptions = {\n      provider: \"token\",\n      credentials: apiKey,\n      tokenHeaderType: \"X_CHROMA_TOKEN\",\n    };\n\n    return new ChromaClient({\n      path: path,\n      auth: auth,\n      database,\n      tenant,","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/chroma-core/chroma/blob/aecdd12c8a891610db8653630b066b32ceb678b5/clients/js/packages/chromadb-core/src/CloudClient.ts#L10-L46","documentation":"Aggregate.from_dict() (operator.py:1412-1413) raises ValueError when given an empty dict {}. An Aggregate dict must name exactly one operator ('$min_k' or '$max_k') whose value carries the keys/k parameters; an empty mapping names none, so there is nothing to construct and the decoder refuses it. This differs deliberately from GroupBy.from_dict, where {} is legal and means 'no grouping' (operator.py:1514-1515) — empty is meaningful for GroupBy but meaningless for Aggregate.","triggerScenarios":"GroupBy.from_dict({\"keys\": [\"category\"], \"aggregate\": {}}) — an explicitly empty aggregate alongside real keys; Aggregate.from_dict({}) direct calls; config templating that emits aggregate: {} when the user left the aggregation section blank; merging configs where all aggregate entries were filtered out.","commonSituations":"Config schemas that require an aggregate key but let it be empty; builders that initialize aggregate = {} and forget to fill it; authors copying the GroupBy empty-dict idiom into aggregate; JSON merge tools that strip unknown operators and leave {} behind.","solutions":["Fill in a real aggregation: {\"aggregate\": {\"$min_k\": {\"keys\": [\"#score\"], \"k\": 3}}} (top-3 per group by relevance).","If you intended no grouping at all, use group_by={} (or omit it) — not an empty aggregate.","Make your config layer reject or default an empty aggregate section instead of forwarding {}.","Remember the two legal aggregate operators are exactly '$min_k' and '$max_k' (operator.py:1422-1429)."],"exampleFix":"// before\ngroup_by = {\"keys\": [\"category\"], \"aggregate\": {}}\n# ValueError: Aggregate dict cannot be empty (via GroupBy.from_dict)\n\n# after\ngroup_by = {\"keys\": [\"category\"], \"aggregate\": {\"$min_k\": {\"keys\": [\"#score\"], \"k\": 3}}}","handlingStrategy":"validation","validationCode":"def aggregate_not_empty(payload: dict) -> bool:\n    return isinstance(payload, dict) and len(payload) > 0","typeGuard":"def is_nonempty_aggregate(v: Any) -> TypeGuard[Dict[str, Any]]:\n    return isinstance(v, dict) and len(v) == 1 and next(iter(v)) in {\"$min_k\", \"$max_k\"}","tryCatchPattern":"try:\n    Aggregate.from_dict(agg)\nexcept ValueError as e:\n    if \"cannot be empty\" in str(e):\n        # decide intent: no grouping, or a missing aggregation spec\n        raise ValueError(\"group_by aggregate cannot be {}; omit group_by for \"\n                         \"no grouping, or supply {'$min_k': {...}}\") from e\n    raise","preventionTips":["{} means 'no grouping' only at the group_by level, never inside aggregate.","Make config schemas require a non-empty aggregate body when the section exists.","Prevent builders from emitting aggregate: {} placeholders."],"tags":["chromadb","aggregate","empty-dict","valueerror","groupby"],"backgroundTag":"empty-required-field","analyzedSha":"aecdd12c8a891610db8653630b066b32ceb678b5","analyzedAt":"2026-08-16T21:53:27.228Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}