mem0ai/mem0 · error · Error
AWS Bedrock model ${this.model} returned no embedding for on
Error message
AWS Bedrock model ${this.model} returned no embedding for one or more inputs What it means
Thrown by the AWS Bedrock embedder after a successful invoke when the response shape is unusable: no embeddings array at all, a count that does not match the number of input texts, or at least one zero-length vector. The explicit zero-length check exists because an empty array is truthy in JS and would otherwise slip through a naive length check and hand the caller a degenerate embedding.
Source
Thrown at mem0-ts/src/oss/src/embeddings/aws_bedrock.ts:255
// Validated outside the try so this message is not re-wrapped by the catch.
// Cohere v3 replies with a flat `embeddings` array; v4 (when
// embedding_types is requested) nests it under `.float`.
const embeddings = this.isCohereModel()
? Array.isArray(payload.embeddings)
? payload.embeddings
: payload.embeddings?.float
: payload.embedding && [payload.embedding];
// `[]` is truthy, so a lone zero-length vector must be checked for
// explicitly -- otherwise it passes the length check and hands the
// caller an empty embedding instead of an error.
if (
!embeddings ||
embeddings.length !== texts.length ||
embeddings.some((embedding) => embedding.length === 0)
) {
throw new Error(
`AWS Bedrock model ${this.model} returned no embedding for one or more inputs`,
);
}
return embeddings;
}
async embed(
text: string,
memoryAction?: "add" | "update" | "search",
): Promise<number[]> {
return (await this.invoke([text], memoryAction))[0];
}
async embedBatch(
texts: string[],
memoryAction?: "add" | "update" | "search",
): Promise<number[][]> {
if (texts.length === 0) return [];View on GitHub (pinned to 001c235229)
Solutions
- Log texts.length and the raw payload (or catch and inspect) to see which of the three conditions fired: missing / count mismatch / zero-length vector
- Filter empty or whitespace-only strings from the batch before embedding
- Reduce batch size below the model's per-request input limit (Cohere embed on Bedrock allows far fewer than unbounded arrays)
- Confirm the configured model name matches the response format you expect — do not mix a v4 model ID with v3 handling assumptions
Example fix
// before const vectors = await embedder.embedBatch(allTexts); // 1 empty string in batch -> zero-length vector // after const clean = allTexts.map((t) => t.trim()).filter((t) => t.length > 0); const vectors = await embedder.embedBatch(clean);
Defensive patterns
Strategy: validation
Validate before calling
const clean = texts.map((t) => t.trim()).filter((t) => t.length > 0);
if (clean.length !== texts.length) {
// decide how to map vectors back if you drop inputs
console.warn(`dropped ${texts.length - clean.length} empty inputs`);
}
await embedder.embedBatch(clean); Try / catch
try {
vectors = await embedder.embedBatch(batch);
} catch (e) {
if (e instanceof Error && e.message.includes('returned no embedding')) {
// data-integrity failure: shrink the batch and retry once; do not use partial vectors
vectors = await embedder.embedBatch(batch.slice(0, Math.ceil(batch.length / 2)));
} else throw e;
} Prevention
- Filter empty/whitespace strings out of every batch before embedding
- Keep batch sizes well under the Bedrock model's per-request input limit
- Treat this error as fail-hard: never proceed with partial or zero-length vectors
When it happens
Trigger: Bedrock returns partial results (batch throttled mid-response); a Cohere v3 flat payload vs v4 payload-shape mismatch; payload.embeddings undefined because the response body was an error object that still parsed as JSON; one input string rejected (e.g. empty text after preprocessing) yielding a null/empty vector.
Common situations: Sending a batch larger than the model limit so the service returns fewer vectors; empty-string inputs in the batch; model family whose response format changed (Cohere v3 'embeddings' vs v4 nested '.float'); intermittent partial responses under load.
Related errors
- Error getting embedding from AWS Bedrock model ${this.model}
- Error getting embedding from AWS Bedrock: {e}
- AWS Bedrock requires both awsAccessKeyId and awsSecretAccess
- The 'boto3' library is required. Please install it using 'pi
- Failed to generate response: {e}
AI-assisted analysis of mem0ai/mem0@001c235229 (2026-08-15).
Data as JSON: /api/errors/ff5547072fad72a9.
Report an issue: GitHub.