{"record":{"id":"63bb6d3daaa41171","repo":"continuedev/continue","slug":"unsupported-embeddings-type-received-number-63bb6d","errorCode":null,"errorMessage":"Unsupported embeddings type received: number[]","messagePattern":"Unsupported embeddings type received: number\\[\\]","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/openai-adapters/src/apis/Bedrock.ts","lineNumber":622,"sourceCode":"    }\n    const decoder = new TextDecoder();\n    const decoded = decoder.decode(response.body);\n    return JSON.parse(decoded);\n  }\n\n  private getEmbedTexts(body: EmbeddingCreateParams): string[] {\n    const texts: string[] = [];\n    if (typeof body.input === \"string\") {\n      texts.push(body.input);\n    } else if (body.input.length > 0) {\n      const firstVal = body.input[0];\n      if (Array.isArray(firstVal)) {\n        throw new Error(\"Unsupported embeddings type received: number[][]\");\n      }\n      if (typeof firstVal === \"string\") {\n        texts.push(...(body.input as string[]));\n      } else {\n        throw new Error(\"Unsupported embeddings type received: number[]\");\n      }\n    }\n    return texts;\n  }\n\n  async embed(body: EmbeddingCreateParams): Promise<CreateEmbeddingResponse> {\n    const texts = this.getEmbedTexts(body);\n\n    let embeddings: number[][];\n    if (body.model.startsWith(\"cohere\")) {\n      const payload = {\n        texts,\n        input_type: \"search_document\",\n        truncate: \"END\",\n      };\n      const output = await this.getInvokeModelResponseBody(body.model, payload);\n      embeddings = [output.embedding];\n    } else if (body.model.startsWith(\"amazon.titan-embed\")) {","sourceCodeStart":604,"sourceCodeEnd":640,"githubUrl":"https://github.com/continuedev/continue/blob/5522c6f44ca0ac3528b37244818fbfa39b5af470/packages/openai-adapters/src/apis/Bedrock.ts#L604-L640","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nconst res = await api.embed({ model: 'bedrock/titan-embed', input: [101, 2054] });\n\n// after\nconst res = await api.embed({ model: 'bedrock/titan-embed', input: ['hello', 'world'] });","handlingStrategy":"type-guard","validationCode":"const ok = Array.isArray(body.input) ? body.input.every(x => typeof x === 'string') : typeof body.input === 'string';\nif (!ok) throw new TypeError('input must be string or string[] for Bedrock');","typeGuard":"function isStringArrayOrString(v: unknown): v is string | string[] {\n  if (typeof v === 'string') return true;\n  return Array.isArray(v) && v.length > 0 && v.every(x => typeof x === 'string');\n}","tryCatchPattern":null,"preventionTips":["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."],"tags":["bedrock","embeddings","input-validation","type-mismatch"],"backgroundTag":"invalid-request-parameter","analyzedSha":"5522c6f44ca0ac3528b37244818fbfa39b5af470","analyzedAt":"2026-08-27T11:28:54.683Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}