lancedb/lancedb · error · Error

Cannot infer list vector. Cannot infer inner type

Error message

Cannot infer list vector.  Cannot infer inner type: ${error}

What it means

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: ...'.

Solutions

  1. Provide an explicit List type to makeVector instead of relying on inference
  2. Ensure the first inner list contains at least one non-null, inferable value
  3. Normalize inner values to a single consistent type (e.g. all numbers) before building the vector

Example fix

// before
const v = makeVector([[null, null]]);
// after
const v = makeVector([[null, null]], new List(new Field('item', new Float32())));
Defensive patterns

Strategy: type-guard

Validate before calling

function innerListInferrable(list) {
  return list.some(v => v !== null && v !== undefined);
}
if (!innerListInferrable(lists[0])) throw new Error('provide explicit inner type');

Try / catch

try {
  vec = makeVector(lists);
} catch (e) {
  if (String(e).includes('Cannot infer inner type')) {
    vec = makeVector(lists, new List(new Field('item', new Float64())));
  } else throw e;
}

Prevention

When it happens

Trigger: makeVector([[null, null]]) or makeVector([[{}]]) — the inner list cannot be type-inferred, so the outer list inference fails.

Common situations: List columns whose first row contains only nulls; mixed-type inner arrays that Apache Arrow cannot unify.

Understand the failure class

Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.

Related errors


AI-assisted analysis of lancedb/lancedb@c7b051aff7 (2026-09-08). Data as JSON: /api/errors/765ba81839e96d1b. Report an issue: GitHub.

Appendix: source

Thrown at nodejs/lancedb/arrow.ts:532

}

/**
 * Helper function to convert Array<Array<any>> to a variable sized list array
 */
// @ts-expect-error (Vector<unknown> is not assignable to Vector<any>)
function makeListVector(lists: unknown[][]): Vector<unknown> {
  if (lists.length === 0 || lists[0].length === 0) {
    throw Error("Cannot infer list vector from empty array or empty list");
  }
  const sampleList = lists[0];
  // biome-ignore lint/suspicious/noExplicitAny: skip
  let inferredType: any;
  try {
    const sampleVector = makeVector(sampleList);
    inferredType = sampleVector.type;
  } catch (error: unknown) {
    // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
    throw Error(`Cannot infer list vector.  Cannot infer inner type: ${error}`);
  }

  const listBuilder = makeBuilder({
    type: new List(new Field("item", inferredType, true)),
  });
  for (const list of lists) {
    listBuilder.append(list);
  }
  return listBuilder.finish().toVector();
}

/** Helper function to convert an Array of JS values to an Arrow Vector */
function makeVector(
  values: unknown[],
  type?: DataType,
  stringAsDictionary?: boolean,
  nullable?: boolean,
  // biome-ignore lint/suspicious/noExplicitAny: skip

View on GitHub (pinned to c7b051aff7)