{"record":{"id":"765ba81839e96d1b","repo":"lancedb/lancedb","slug":"cannot-infer-list-vector-cannot-infer-inner-type","errorCode":null,"errorMessage":"Cannot infer list vector.  Cannot infer inner type: ${error}","messagePattern":"Cannot infer list vector\\.  Cannot infer inner type: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"nodejs/lancedb/arrow.ts","lineNumber":532,"sourceCode":"}\n\n/**\n * Helper function to convert Array<Array<any>> to a variable sized list array\n */\n// @ts-expect-error (Vector<unknown> is not assignable to Vector<any>)\nfunction makeListVector(lists: unknown[][]): Vector<unknown> {\n  if (lists.length === 0 || lists[0].length === 0) {\n    throw Error(\"Cannot infer list vector from empty array or empty list\");\n  }\n  const sampleList = lists[0];\n  // biome-ignore lint/suspicious/noExplicitAny: skip\n  let inferredType: any;\n  try {\n    const sampleVector = makeVector(sampleList);\n    inferredType = sampleVector.type;\n  } catch (error: unknown) {\n    // eslint-disable-next-line @typescript-eslint/restrict-template-expressions\n    throw Error(`Cannot infer list vector.  Cannot infer inner type: ${error}`);\n  }\n\n  const listBuilder = makeBuilder({\n    type: new List(new Field(\"item\", inferredType, true)),\n  });\n  for (const list of lists) {\n    listBuilder.append(list);\n  }\n  return listBuilder.finish().toVector();\n}\n\n/** Helper function to convert an Array of JS values to an Arrow Vector */\nfunction makeVector(\n  values: unknown[],\n  type?: DataType,\n  stringAsDictionary?: boolean,\n  nullable?: boolean,\n  // biome-ignore lint/suspicious/noExplicitAny: skip","sourceCodeStart":514,"sourceCodeEnd":550,"githubUrl":"https://github.com/lancedb/lancedb/blob/c7b051aff7039333a3f61b79217246c27676806a/nodejs/lancedb/arrow.ts#L514-L550","documentation":"After sampling the first inner list, makeListVector tries makeVector(sampleList) to infer the list's element type. If that nested inference throws (e.g. all nulls, unsupported value shapes), the error is rethrown wrapped as 'Cannot infer list vector. Cannot infer inner type: ...'.","triggerScenarios":"makeVector([[null, null]]) or makeVector([[{}]]) — the inner list cannot be type-inferred, so the outer list inference fails.","commonSituations":"List columns whose first row contains only nulls; mixed-type inner arrays that Apache Arrow cannot unify.","solutions":["Provide an explicit List type to makeVector instead of relying on inference","Ensure the first inner list contains at least one non-null, inferable value","Normalize inner values to a single consistent type (e.g. all numbers) before building the vector"],"exampleFix":"// before\nconst v = makeVector([[null, null]]);\n// after\nconst v = makeVector([[null, null]], new List(new Field('item', new Float32())));","handlingStrategy":"type-guard","validationCode":"function innerListInferrable(list) {\n  return list.some(v => v !== null && v !== undefined);\n}\nif (!innerListInferrable(lists[0])) throw new Error('provide explicit inner type');","typeGuard":null,"tryCatchPattern":"try {\n  vec = makeVector(lists);\n} catch (e) {\n  if (String(e).includes('Cannot infer inner type')) {\n    vec = makeVector(lists, new List(new Field('item', new Float64())));\n  } else throw e;\n}","preventionTips":["Ensure the first inner list has at least one non-null value","Use consistent element types inside lists","Prefer explicit List/Field types over inference"],"tags":["nodejs","arrow","type-inference","null-values"],"backgroundTag":"type-mismatch","analyzedSha":"c7b051aff7039333a3f61b79217246c27676806a","analyzedAt":"2026-09-08T23:42:37.579Z","contentChangedAt":"2026-09-08T23:42:37.579Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}