FlowiseAI/Flowise · error · Error
cannot provide both `filter` and `this.filter`
Error message
cannot provide both `filter` and `this.filter`
What it means
similaritySearchVectorWithScore forbids passing a per-call filter when the instance was already constructed with this.filter, to avoid ambiguity about which filter wins. Pick one source of truth.
Source
Thrown at packages/components/nodes/vectorstores/Chroma/core.ts:208
where: { ...params.filter }
})
} else {
throw new Error(`You must provide one of "ids or "filter".`)
}
}
/**
* Searches for vectors in the Chroma database that are similar to the
* provided query vector. The search can be filtered using the provided
* `filter` object or the `filter` property of the `Chroma` instance.
* @param query The query vector.
* @param k The number of similar vectors to return.
* @param filter Optional. A `filter` object to filter the search results.
* @returns A promise that resolves with an array of tuples, each containing a `Document` instance and a similarity score.
*/
async similaritySearchVectorWithScore(query: number[], k: number, filter?: this['FilterType']) {
if (filter && this.filter) {
throw new Error('cannot provide both `filter` and `this.filter`')
}
const _filter = filter ?? this.filter
const where = _filter === undefined ? undefined : { ..._filter }
const collection = await this.ensureCollection()
// similaritySearchVectorWithScore supports one query vector at a time
// chroma supports multiple query vectors at a time
const result = await collection.query({
queryEmbeddings: [query],
nResults: k,
where
})
const { ids, distances, documents, metadatas } = result
if (!ids || !distances || !documents || !metadatas) {
return []
}View on GitHub (pinned to abe4a8601a)
Solutions
- If you need a per-query filter, construct the Chroma instance without this.filter.
- If the instance filter is what you want, drop the per-call filter argument.
- Build two instances (one with the default filter, one without) for the two use cases.
Example fix
// before
const store = new Chroma(embeddings, { filter: { author: 'x' } })
await store.similaritySearchVectorWithScore(q, k, { author: 'y' }) // throws
// after
const store = new Chroma(embeddings, {}) // no instance filter
await store.similaritySearchVectorWithScore(q, k, { author: 'y' }) Defensive patterns
Strategy: validation
Validate before calling
function canApplyPerCallFilter(store: Chroma, filter?: unknown): boolean {
return !filter || !store.filter // ok if either is absent
}
if (!canApplyPerCallFilter(store, perCallFilter)) {
throw new Error('Conflicting filters: instance filter and per-call filter both set')
} Type guard
function hasInstanceFilter(store: { filter?: unknown }): boolean {
return store.filter !== undefined && store.filter !== null
} Try / catch
try {
await store.similaritySearchVectorWithScore(q, k, filter)
} catch (e) {
if (/both .filter./i.test(String(e))) {
// drop the instance filter by reconstructing without it
const bare = new Chroma(store.embeddings, { ...store.clientParams })
await bare.similaritySearchVectorWithScore(q, k, filter)
} else throw e
} Prevention
- Pick one filter source: instance-level or per-call, never both.
- Build a helper that always reconstructs a fresh store for per-query filters.
- Document store reuse assumptions.
When it happens
Trigger: Chroma instance created with `new Chroma(..., { filter })` and the caller also passes a third-argument filter to similaritySearch / similaritySearchVectorWithScore.
Common situations: Reusable singleton store with a default filter, then a per-query override attempted; copy-paste between code paths that set filters differently.
Related errors
- You must provide one of "ids or "filter".
- chatflowId must be a valid array
- dataset.rows must be a valid array
- Search request failed: ${searchResponse.warning || 'Unknown
- Firecrawl: Query is required for search mode
AI-assisted analysis of FlowiseAI/Flowise@abe4a8601a (2026-08-12).
Data as JSON: /api/errors/77b1d8b5c81c46fb.
Report an issue: GitHub.