n8n-io/n8n · error · UnexpectedError
Unexpected score type: ${typeof score}
Error message
Unexpected score type: ${typeof score} What it means
An UnexpectedError thrown while mapping hybridSearch results: each document's metadata.score must be a number, and if it is not (string, undefined, object) the mapping aborts. This fires only on the hybrid search branch (args.hybridQuery) where returnMetadata may be ['explainScore']. It signals the Weaviate response shape differs from what n8n expects.
Source
Thrown at packages/@n8n/nodes-langchain/nodes/vector_store/VectorStoreWeaviate/VectorStoreWeaviate.node.ts:82
if (args.hybridQuery) {
const options = {
limit: k ?? undefined,
autoLimit: args.autoCutLimit ?? undefined,
alpha: args.alpha ?? undefined,
vector: query,
filter: filter ? parseCompositeFilter(filter as WeaviateCompositeFilter) : undefined,
queryProperties: args.queryProperties
? args.queryProperties.split(',').map((prop) => prop.trim())
: undefined,
maxVectorDistance: args.maxVectorDistance ?? undefined,
fusionType: args.fusionType,
returnMetadata: args.hybridExplainScore ? ['explainScore'] : undefined,
};
const content = await super.hybridSearch(args.hybridQuery, options);
return content.map((doc) => {
const { score, ...metadata } = doc.metadata;
if (typeof score !== 'number') {
throw new UnexpectedError(`Unexpected score type: ${typeof score}`);
}
return [
new Document({
pageContent: doc.pageContent,
metadata,
}),
score,
] as [Document, number];
});
}
return await super.similaritySearchVectorWithScore(
query,
k,
filter ? parseCompositeFilter(filter as WeaviateCompositeFilter) : undefined,
);
}
}
View on GitHub (pinned to 5ac6606e81)
Solutions
- If you enabled hybridExplainScore, disable it for the retrieval call that needs numeric scores (this branch only exists because of the hybrid path).
- Update n8n to the latest release in case the metadata-shape handling was patched.
- Check the Weaviate server version against the version n8n's bundled client expects; align them.
- If you need explain output, consume it separately from the scoring path so the numeric score mapping is unaffected.
Example fix
// before: options.hybridExplainScore = true (score becomes explain object) // after: options.hybridExplainScore = false (metadata.score is a number again)
Defensive patterns
Strategy: type-guard
Validate before calling
// guard the mapping yourself before relying on numeric scores
const score = (doc.metadata as any).score;
if (typeof score !== 'number') { /* fallback to similaritySearchVectorWithScore, or disable hybridExplainScore */ } Type guard
function hasNumericScore(m: unknown): m is { score: number } { return typeof (m as any)?.score === 'number'; } Try / catch
try { results = await store.hybridSearch(...) } catch (e) { if (/Unexpected score type/.test(e.message)) { results = await store.similaritySearchVectorWithScore(query, k); } else throw e; } Prevention
- Disable hybridExplainScore when you need numeric scores downstream.
- Do not assume metadata.score is always present after Weaviate upgrades.
- Pin a compatible Weaviate server version for your n8n release.
- Add a type guard at the boundary that consumes hybrid results.
When it happens
Trigger: hybridSearch returns documents whose metadata.score is not a number — e.g. when hybridExplainScore is enabled and Weaviate returns an explanation object/string instead of a numeric score, or when a weaviate-ts/langchain version change alters metadata.score's type.
Common situations: Enabling hybridExplainScore changes the returned metadata so score is no longer numeric; weaviate server version returns score under a different key; langchain Document.metadata typing drift after an upgrade.
Related errors
- Filter operator "${operator}" on key "${key}" requires array
- Filter operator "${operator}" on key "${key}" requires a str
- Metadata key "${CONTENT_KEY}" is reserved for the document c
- Metadata value for key "${key}" is unsupported: Pinecone onl
- Filter operator "${operator}" on key "${key}" requires all a
AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12).
Data as JSON: /api/errors/61533a3a956027e9.
Report an issue: GitHub.