{"record":{"id":"77b1d8b5c81c46fb","repo":"FlowiseAI/Flowise","slug":"cannot-provide-both-filter-and-this-filter","errorCode":null,"errorMessage":"cannot provide both `filter` and `this.filter`","messagePattern":"cannot provide both `filter` and `this\\.filter`","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/components/nodes/vectorstores/Chroma/core.ts","lineNumber":208,"sourceCode":"                where: { ...params.filter }\n            })\n        } else {\n            throw new Error(`You must provide one of \"ids or \"filter\".`)\n        }\n    }\n\n    /**\n     * Searches for vectors in the Chroma database that are similar to the\n     * provided query vector. The search can be filtered using the provided\n     * `filter` object or the `filter` property of the `Chroma` instance.\n     * @param query The query vector.\n     * @param k The number of similar vectors to return.\n     * @param filter Optional. A `filter` object to filter the search results.\n     * @returns A promise that resolves with an array of tuples, each containing a `Document` instance and a similarity score.\n     */\n    async similaritySearchVectorWithScore(query: number[], k: number, filter?: this['FilterType']) {\n        if (filter && this.filter) {\n            throw new Error('cannot provide both `filter` and `this.filter`')\n        }\n        const _filter = filter ?? this.filter\n        const where = _filter === undefined ? undefined : { ..._filter }\n\n        const collection = await this.ensureCollection()\n\n        // similaritySearchVectorWithScore supports one query vector at a time\n        // chroma supports multiple query vectors at a time\n        const result = await collection.query({\n            queryEmbeddings: [query],\n            nResults: k,\n            where\n        })\n\n        const { ids, distances, documents, metadatas } = result\n        if (!ids || !distances || !documents || !metadatas) {\n            return []\n        }","sourceCodeStart":190,"sourceCodeEnd":226,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/components/nodes/vectorstores/Chroma/core.ts#L190-L226","documentation":"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.","triggerScenarios":"Chroma instance created with `new Chroma(..., { filter })` and the caller also passes a third-argument filter to similaritySearch / similaritySearchVectorWithScore.","commonSituations":"Reusable singleton store with a default filter, then a per-query override attempted; copy-paste between code paths that set filters differently.","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."],"exampleFix":"// before\nconst store = new Chroma(embeddings, { filter: { author: 'x' } })\nawait store.similaritySearchVectorWithScore(q, k, { author: 'y' }) // throws\n\n// after\nconst store = new Chroma(embeddings, {}) // no instance filter\nawait store.similaritySearchVectorWithScore(q, k, { author: 'y' })","handlingStrategy":"validation","validationCode":"function canApplyPerCallFilter(store: Chroma, filter?: unknown): boolean {\n  return !filter || !store.filter // ok if either is absent\n}\nif (!canApplyPerCallFilter(store, perCallFilter)) {\n  throw new Error('Conflicting filters: instance filter and per-call filter both set')\n}","typeGuard":"function hasInstanceFilter(store: { filter?: unknown }): boolean {\n  return store.filter !== undefined && store.filter !== null\n}","tryCatchPattern":"try {\n  await store.similaritySearchVectorWithScore(q, k, filter)\n} catch (e) {\n  if (/both .filter./i.test(String(e))) {\n    // drop the instance filter by reconstructing without it\n    const bare = new Chroma(store.embeddings, { ...store.clientParams })\n    await bare.similaritySearchVectorWithScore(q, k, filter)\n  } else throw e\n}","preventionTips":["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."],"tags":["chroma","search","filter","api-contract"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}