FlowiseAI/Flowise · error · Error

cannot provide both `filter` and `this.filter`

Error message

cannot provide both `filter` and `this.filter`

What it means

similaritySearchVectorWithScore() rejects calls when a runtime `filter` argument is passed AND the store instance was constructed with an instance filter (this.filter). This mirrors upstream LangChain JS ZepVectorStore behavior; the two filter sources are mutually exclusive to avoid ambiguity about which one applies.

Source

Thrown at packages/components/nodes/vectorstores/Zep/Zep.ts:243

            )
        }

        this.collection = await this.client.document.addCollection({
            name: args.collectionName,
            description: args.description,
            metadata: args.metadata,
            embeddingDimensions: args.embeddingDimensions,
            isAutoEmbedded: false
        })
    }

    async similaritySearchVectorWithScore(
        query: number[],
        k: number,
        filter?: Record<string, unknown> | undefined
    ): Promise<[Document, number][]> {
        if (filter && this.filter) {
            throw new Error('cannot provide both `filter` and `this.filter`')
        }
        const _filters = filter ?? this.filter
        const ANDFilters = []
        for (const filterKey in _filters) {
            let filterVal = _filters[filterKey]
            if (typeof filterVal === 'string') filterVal = `"${filterVal}"`
            ANDFilters.push({ jsonpath: `$[*] ? (@.${filterKey} == ${filterVal})` })
        }
        const newfilter = {
            where: { and: ANDFilters }
        }
        await this.initializeCollection(this.args!).catch((err) => {
            console.error('Error initializing collection:', err)
            throw err
        })
        const results = await this.collection.search(
            {
                embedding: new Float32Array(query),

View on GitHub (pinned to abe4a8601a)

Solutions

  1. Pick one filter source: either set zepMetadataFilter on the store config OR pass filter at call time — not both.
  2. If per-query filtering is required, construct the store without zepMetadataFilter and pass the filter at each similaritySearch call.
  3. If the store must hold a default filter, do not pass a runtime filter; clear this.filter (re-instantiate) before passing one.

Example fix

// before: store built with filter AND runtime filter passed
const store = new ZepVectorStore({ ..., filter: defaultFilter })
store.similaritySearchVectorWithScore(q, k, perQueryFilter) // throws

// after: pick one source
const store = new ZepVectorStore({ ... }) // no instance filter
store.similaritySearchVectorWithScore(q, k, perQueryFilter)
Defensive patterns

Strategy: validation

Validate before calling

// Ensure only one filter source is used
function assertSingleFilterSource(instanceFilter, runtimeFilter) {
    if (instanceFilter && runtimeFilter) {
        throw new Error('Pass filter either at construction OR at call time, not both')
    }
}

Type guard

function canPassRuntimeFilter(store) {
    return !store.filter // only safe when no instance filter is set
}

Try / catch

try {
    await store.similaritySearchVectorWithScore(query, k, filter)
} catch (e) {
    if (/cannot provide both/i.test(e.message)) {
        // rebuild the store without zepMetadataFilter and retry with the runtime filter
    }
    throw e
}

Prevention

When it happens

Trigger: Caller invokes similaritySearchVectorWithScore(query, k, filterObj) on a ZepVectorStore whose constructor config included a `filter` (Flowise wires zepMetadataFilter into the store config).

Common situations: Flowise passes zepMetadataFilter through the store config AND a per-query filter at call time; custom code reuses a long-lived store instance that was constructed with a filter and then passes another filter per query.

Related errors


AI-assisted analysis of FlowiseAI/Flowise@abe4a8601a (2026-08-12). Data as JSON: /api/errors/53d494ae661c7fca. Report an issue: GitHub.