lancedb/lancedb · error · Error

Expected an Int Type to have a `bitWidth` and `isSigned`…

Error message

Expected an Int Type to have a `bitWidth` and `isSigned` property

What it means

sanitizeInt rebuilds an Arrow Int type from a plain object and requires `bitWidth` and `isSigned`. If the provided type-like object is missing or has wrongly typed values for these fields, it throws — the input was not a recognizable Arrow Int type.

Solutions

  1. Use actual apache-arrow type instances (new Int(true, 32), Int32, etc.) rather than plain objects
  2. When round-tripping through JSON, preserve bitWidth and isSigned and restore them before use
  3. Check that apache-arrow and lancedb versions are compatible

Example fix

// before
const t = { typeId: Type.Int };
// after
import { Int } from 'apache-arrow';
const t = new Int(true, 32);
Defensive patterns

Strategy: type-guard

Validate before calling

function looksLikeIntType(t) {
  return t && typeof t.bitWidth === 'number' && typeof t.isSigned === 'boolean';
}
if (!looksLikeIntType(candidateType)) throw new Error('rebuild Int type with bitWidth/isSigned');

Type guard

const isIntLike = (t: unknown): t is { bitWidth: number; isSigned: boolean } =>
  typeof t === 'object' && t !== null &&
  'bitWidth' in t && typeof (t as any).bitWidth === 'number' &&
  'isSigned' in t && typeof (t as any).isSigned === 'boolean';

Try / catch

try {
  sanitized = sanitizeSchema(schema);
} catch (e) {
  if (String(e).includes('bitWidth')) {
    // rebuild the field type with new Int(isSigned, bitWidth) and retry
  } else throw e;
}

Prevention

When it happens

Trigger: Passing a hand-built or partially deserialized type object (e.g. from JSON that dropped the Int properties) into schema sanitization.

Common situations: Serializing a schema to JSON and reconstructing it without preserving bitWidth/isSigned; using types from a mismatched apache-arrow version.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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

Appendix: source

Thrown at nodejs/lancedb/sanitize.ts:124

  for (const [key, value] of entries) {
    if (typeof key !== "string" || typeof value !== "string") {
      throw Error(
        "Expected metadata, if present, to be a Map<string, string> but it had non-string keys or values",
      );
    }
    metadata.set(key, value);
  }
  return metadata;
}

export function sanitizeInt(typeLike: object) {
  if (
    !("bitWidth" in typeLike) ||
    typeof typeLike.bitWidth !== "number" ||
    !("isSigned" in typeLike) ||
    typeof typeLike.isSigned !== "boolean"
  ) {
    throw Error(
      "Expected an Int Type to have a `bitWidth` and `isSigned` property",
    );
  }
  return new Int(typeLike.isSigned, typeLike.bitWidth as IntBitWidth);
}

export function sanitizeFloat(typeLike: object) {
  if (!("precision" in typeLike) || typeof typeLike.precision !== "number") {
    throw Error("Expected a Float Type to have a `precision` property");
  }
  return new Float(typeLike.precision as Precision);
}

export function sanitizeDecimal(typeLike: object) {
  if (
    !("scale" in typeLike) ||
    typeof typeLike.scale !== "number" ||
    !("precision" in typeLike) ||

View on GitHub (pinned to c7b051aff7)