FlowiseAI/Flowise · error · Error
Invalid Similarity Metric should be one of 'cosine' | 'eucli
Error message
Invalid Similarity Metric should be one of 'cosine' | 'euclidean' | 'dot_product'
What it means
Thrown in Astra vectorStoreMethods.upsert when `similarityMetric` is set but not one of 'cosine', 'euclidean', 'dot_product'. The validation runs before any Astra client is created, so it is purely an input-config check. The same check exists in init (error 498).
Source
Thrown at packages/components/nodes/vectorstores/Astra/Astra.ts:109
name: 'vectorStore',
baseClasses: [this.type, ...getBaseClasses(AstraDBVectorStore)]
}
]
}
//@ts-ignore
vectorStoreMethods = {
async upsert(nodeData: INodeData, options: ICommonObject): Promise<Partial<IndexingResult>> {
const docs = nodeData.inputs?.document as Document[]
const embeddings = nodeData.inputs?.embeddings as Embeddings
const vectorDimension = nodeData.inputs?.vectorDimension as number
const astraCollection = nodeData.inputs?.astraCollection as string
const similarityMetric = nodeData.inputs?.similarityMetric as 'cosine' | 'euclidean' | 'dot_product' | undefined
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
const expectedSimilarityMetric = ['cosine', 'euclidean', 'dot_product']
if (similarityMetric && !expectedSimilarityMetric.includes(similarityMetric)) {
throw new Error(`Invalid Similarity Metric should be one of 'cosine' | 'euclidean' | 'dot_product'`)
}
const clientConfig = {
token: credentialData?.applicationToken,
endpoint: credentialData?.dbEndPoint
}
const astraConfig: AstraLibArgs = {
...clientConfig,
collection: astraCollection ?? credentialData.collectionName ?? 'flowise_test',
collectionOptions: {
vector: {
dimension: vectorDimension ?? 1536,
metric: similarityMetric ?? 'cosine'
}
}
}
View on GitHub (pinned to abe4a8601a)
Solutions
- Set the similarity metric to one of 'cosine', 'euclidean', or 'dot_product'.
- Leave the field unset to use the Astra default rather than supplying an invalid value.
- Normalize input to lowercase before validation if casing is the issue (but the allowed set is lowercase only).
Example fix
// before similarityMetric = 'manhattan' // throws: Invalid Similarity Metric ... // after similarityMetric = 'cosine' // or 'euclidean' | 'dot_product'
Defensive patterns
Strategy: validation
Validate before calling
const ALLOWED_ASTRA_METRICS = ['cosine', 'euclidean', 'dot_product'] as const
type AstraMetric = typeof ALLOWED_ASTRA_METRICS[number]
function normalizeMetric(v: unknown): AstraMetric | undefined {
if (v == null || v === '') return undefined
const lower = String(v).toLowerCase()
if (!ALLOWED_ASTRA_METRICS.includes(lower as AstraMetric)) {
throw new Error(`similarityMetric must be one of ${ALLOWED_ASTRA_METRICS.join('|')}, got: ${String(v)}`)
}
return lower as AstraMetric
}
// before upsert
normalizeMetric(nodeData.inputs?.similarityMetric) Type guard
const isAstraMetric = (v: unknown): v is 'cosine' | 'euclidean' | 'dot_product' => typeof v === 'string' && ['cosine', 'euclidean', 'dot_product'].includes(v)
Try / catch
try { return await astraNode.vectorStoreMethods.upsert(nodeData, options) }
catch (e) {
if (/Invalid Similarity Metric/.test((e as Error).message)) {
throw new Error('Set similarityMetric to cosine|euclidean|dot_product (or leave unset)')
}
throw e
} Prevention
- Constrain the metric field in the UI/API to a dropdown of allowed values.
- Normalize to lowercase before passing to the node.
- Leave unset rather than guessing if the desired value is unclear.
When it happens
Trigger: A user selects or types a similarity metric value outside the allowed set (e.g. 'manhattan', 'Cosine' with wrong casing, 'dot', empty-but-defined).
Common situations: Custom metric typed manually; case mismatch; stale flow referencing a previously-supported metric; typo in API-driven flow creation.
Related errors
- Invalid path: path must be within allowed directories (${all
- Model is required
- Model is required
- Scenarios are required
- Invalid JSON in executeFlowOverrideConfig: ${parseError.mess
AI-assisted analysis of FlowiseAI/Flowise@abe4a8601a (2026-08-12).
Data as JSON: /api/errors/4217040e000e2e80.
Report an issue: GitHub.