{"record":{"id":"52e8b0914816b2c0","repo":"lancedb/lancedb","slug":"expected-a-struct-type-to-have-an-array-like-chil","errorCode":null,"errorMessage":"Expected a Struct type to have an array-like `children` property","messagePattern":"Expected a Struct type to have an array-like `children` property","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"nodejs/lancedb/sanitize.ts","lineNumber":237,"sourceCode":"      \"Expected a List type to have an array-like `children` property\",\n    );\n  }\n  if (typeLike.children.length !== 1) {\n    throw Error(\"Expected a List type to have exactly one child\");\n  }\n  return new List(sanitizeFieldWithContext(typeLike.children[0], context));\n}\n\nexport function sanitizeStruct(typeLike: object) {\n  return sanitizeStructWithContext(typeLike, createSanitizationContext());\n}\n\nfunction sanitizeStructWithContext(\n  typeLike: object,\n  context: SanitizationContext,\n) {\n  if (!(\"children\" in typeLike) || !Array.isArray(typeLike.children)) {\n    throw Error(\n      \"Expected a Struct type to have an array-like `children` property\",\n    );\n  }\n  return new Struct(\n    typeLike.children.map((child) => sanitizeFieldWithContext(child, context)),\n  );\n}\n\nexport function sanitizeUnion(typeLike: object) {\n  return sanitizeUnionWithContext(typeLike, createSanitizationContext());\n}\n\nfunction sanitizeUnionWithContext(\n  typeLike: object,\n  context: SanitizationContext,\n) {\n  if (\n    !(\"typeIds\" in typeLike) ||","sourceCodeStart":219,"sourceCodeEnd":255,"githubUrl":"https://github.com/lancedb/lancedb/blob/c7b051aff7039333a3f61b79217246c27676806a/nodejs/lancedb/sanitize.ts#L219-L255","documentation":"sanitizeStructWithContext validates that a serialized Struct type has a `children` property that is an array; each element is recursively sanitized into the struct's fields. Missing or non-array children mean the descriptor cannot represent an Arrow Struct, so it throws before constructing an invalid type.","triggerScenarios":"sanitizeStruct({}) (no children), sanitizeStruct({children: 'name,type'}), or children as a map/object rather than an array; also reached via sanitizeTypeById on typeId Struct.","commonSituations":"Struct schemas serialized as keyed objects {fieldName: type} instead of arrays of fields by custom serializers; nested metadata dropped during JSON round-trip; hand-built descriptors forgetting the fields array.","solutions":["Provide `children` as an array of field-like objects, one per struct field.","Pass a real arrow.Struct([...fields]) instance instead of a plain object.","Convert keyed-object serializations to an explicit field array before sanitizing."],"exampleFix":"// before\nsanitizeStruct({ name: 'id', name: 'value' });\n// after\nsanitizeStruct({ children: [{ name: 'id', type: { typeId: 2 } }, { name: 'value', type: { typeId: 2 } }] });","handlingStrategy":"validation","validationCode":"function assertStructLike(t) {\n  if (!Array.isArray(t?.children)) {\n    throw new TypeError('struct type requires children array of fields');\n  }\n}","typeGuard":"function isStructLike(t: object): t is { children: unknown[] } {\n  return \"children\" in t && Array.isArray((t as any).children);\n}","tryCatchPattern":"try {\n  const type = sanitizeStruct(typeLike);\n} catch (e) {\n  if (e.message.includes('Struct type to have an array-like')) {\n    // convert keyed-object struct serialization to a field array, then retry\n  }\n  throw e;\n}","preventionTips":["Represent struct fields as an array, not a keyed object, in your serialization format.","Use arrow.Struct with an explicit Field list rather than ad-hoc objects.","Round-trip struct-containing schemas in tests whenever serialization code changes."],"tags":["typescript","schema","arrow","struct"],"backgroundTag":"invalid-argument-format","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"}