continuedev/continue · error · Error
Unsupported embeddings type received: number[]
Error message
Unsupported embeddings type received: number[]
What it means
Companion check in getEmbedTexts: input is an array whose first element is neither an array nor a string — i.e. a flat array of numbers (token IDs, number[][]/number[] style pre-tokenized input). Bedrock embeddings require string inputs, so the adapter rejects it client-side with a clear message instead of sending an invalid AWS request.
Source
Thrown at packages/openai-adapters/src/apis/Bedrock.ts:622
}
const decoder = new TextDecoder();
const decoded = decoder.decode(response.body);
return JSON.parse(decoded);
}
private getEmbedTexts(body: EmbeddingCreateParams): string[] {
const texts: string[] = [];
if (typeof body.input === "string") {
texts.push(body.input);
} else if (body.input.length > 0) {
const firstVal = body.input[0];
if (Array.isArray(firstVal)) {
throw new Error("Unsupported embeddings type received: number[][]");
}
if (typeof firstVal === "string") {
texts.push(...(body.input as string[]));
} else {
throw new Error("Unsupported embeddings type received: number[]");
}
}
return texts;
}
async embed(body: EmbeddingCreateParams): Promise<CreateEmbeddingResponse> {
const texts = this.getEmbedTexts(body);
let embeddings: number[][];
if (body.model.startsWith("cohere")) {
const payload = {
texts,
input_type: "search_document",
truncate: "END",
};
const output = await this.getInvokeModelResponseBody(body.model, payload);
embeddings = [output.embedding];
} else if (body.model.startsWith("amazon.titan-embed")) {View on GitHub (pinned to 5522c6f44c)
Solutions
- Ensure every element of input is a string; cast/convert numbers via String(...) only if they were meant as text.
- If the numbers are token IDs, decode to text with the originating tokenizer first.
- Validate input shape before calling embed.
Example fix
// before
const res = await api.embed({ model: 'bedrock/titan-embed', input: [101, 2054] });
// after
const res = await api.embed({ model: 'bedrock/titan-embed', input: ['hello', 'world'] }); Defensive patterns
Strategy: type-guard
Validate before calling
const ok = Array.isArray(body.input) ? body.input.every(x => typeof x === 'string') : typeof body.input === 'string';
if (!ok) throw new TypeError('input must be string or string[] for Bedrock'); Type guard
function isStringArrayOrString(v: unknown): v is string | string[] {
if (typeof v === 'string') return true;
return Array.isArray(v) && v.length > 0 && v.every(x => typeof x === 'string');
} Prevention
- Never send flat number arrays (token IDs) as embedding input.
- Sanitize dynamic inputs: String(value) before embedding.
- Add unit tests asserting string-only inputs in Bedrock pipelines.
When it happens
Trigger: Calling embed with input: [1, 2, 3] (flat number array of token IDs); mixing types like [42, 'text']; passing numeric IDs from an upstream tokenizer.
Common situations: Same as token-array scenarios: OpenAI-compatible code that sends token IDs, dynamic inputs coerced to numbers, or a JSON config supplying numbers where strings were intended.
Related errors
- Unsupported embeddings type received: number[][]
- Unsupported model: ${body.model}
- Query and chunks must not be empty
- Failed to fetch messages: ${response.statusText}
- Continue currently only supports text resources from MCP
AI-assisted analysis of continuedev/continue@5522c6f44c (2026-08-27).
Data as JSON: /api/errors/63bb6d3daaa41171.
Report an issue: GitHub.