chroma-core/chroma · error · Error

limit can only be specified when a where or whereDocument…

Error message

limit can only be specified when a where or whereDocument clause is provided

What it means

Validation in Collection.validateDelete (called from delete): a limit parameter on delete is only meaningful as a cap on a filtered deletion, so passing limit without a where or whereDocument clause is rejected to prevent an unbounded, ambiguous delete.

Solutions

  1. Add a where or whereDocument clause alongside limit.
  2. Remove the limit argument to delete all matching records.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at clients/new-js/packages/chromadb/src/collection.ts:862 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at clients/new-js/packages/chromadb/src/collection.ts:862

      ids,
      embeddings,
    };
  }

  private validateDelete(
    ids?: string[],
    where?: Where,
    whereDocument?: WhereDocument,
    limit?: number,
  ) {
    if (ids) validateIDs(ids);
    if (where) validateWhere(where);
    if (whereDocument) validateWhereDocument(whereDocument);
    if (limit !== undefined && (!Number.isInteger(limit) || limit < 0)) {
      throw new Error("limit must be a non-negative integer");
    }
    if (limit !== undefined && !where && !whereDocument) {
      throw new Error(
        "limit can only be specified when a where or whereDocument clause is provided",
      );
    }
  }

  public async count(options?: { readLevel?: ReadLevel }): Promise<number> {
    const { data } = await RecordService.collectionCount({
      client: this.apiClient,
      path: await this.path(),
      query: options?.readLevel ? { read_level: options.readLevel } : undefined,
    });

    return data;
  }

  public async add({
    ids,
    embeddings,

View on GitHub (pinned to aecdd12c8a)