{"record":{"id":"a5681b35e2f38854","repo":"lancedb/lancedb","slug":"the-schema-passed-in-does-not-appear-to-be-a-schem","errorCode":null,"errorMessage":"The schema passed in does not appear to be a schema (no 'fields' property)","messagePattern":"The schema passed in does not appear to be a schema \\(no 'fields' property\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nodejs/lancedb/sanitize.ts","lineNumber":630,"sourceCode":" * instance because they might be using a different instance of apache-arrow\n * than lancedb is using.\n */\nexport function sanitizeSchema(schemaLike: SchemaLike): Schema {\n  return sanitizeSchemaWithContext(schemaLike, createSanitizationContext());\n}\n\nfunction sanitizeSchemaWithContext(\n  schemaLike: SchemaLike,\n  context: SanitizationContext,\n): Schema {\n  if (schemaLike instanceof Schema) {\n    return schemaLike;\n  }\n  if (typeof schemaLike !== \"object\" || schemaLike === null) {\n    throw Error(\"Expected a Schema but object was null/undefined\");\n  }\n  if (!(\"fields\" in schemaLike)) {\n    throw Error(\n      \"The schema passed in does not appear to be a schema (no 'fields' property)\",\n    );\n  }\n  let metadata;\n  if (\"metadata\" in schemaLike) {\n    metadata = sanitizeMetadata(schemaLike.metadata);\n  }\n  if (!Array.isArray(schemaLike.fields)) {\n    throw Error(\n      \"The schema passed in had a 'fields' property but it was not an array\",\n    );\n  }\n  const sanitizedFields = schemaLike.fields.map((field) =>\n    sanitizeFieldWithContext(field, context),\n  );\n  return new Schema(sanitizedFields, metadata);\n}\n","sourceCodeStart":612,"sourceCodeEnd":648,"githubUrl":"https://github.com/lancedb/lancedb/blob/c7b051aff7039333a3f61b79217246c27676806a/nodejs/lancedb/sanitize.ts#L612-L648","documentation":"sanitizeSchemaWithContext treats an object as schema-like only if it has a `fields` property. An object without `fields` (or with it misspelled) is not a recognizable Schema, so this error is thrown. This is a duck-typing guard for schema objects that crossed a serialization boundary and lost their class identity.","triggerScenarios":"Passing a plain object like `{ metadata: {...} }` or a single Field object where a Schema was expected; passing a Record<string, Field> mapping (column-name keys) instead of `{ fields: [...] }`; typos like `field` or `columns` instead of `fields`.","commonSituations":"Hand-building a schema object and using the wrong key name; passing the output of a different library's schema representation (e.g. a JSON column map); accidentally passing a table or record batch where a schema was required.","solutions":["Wrap your fields in the expected shape: `{ fields: [/* Field-like objects */], metadata: {...} }`.","Prefer constructing a real `new Schema(fields)` from apache-arrow — instances are returned unchanged.","Verify the object actually holds fields: log `Object.keys(obj)` and check for `fields`.","If you have a Record of columns, convert it: `{ fields: Object.entries(cols).map(([name, type]) => new Field(name, type, true)) }`."],"exampleFix":"// before\nconst s = { item: new Field('item', new Utf8(), true) };\nsanitizeSchema(s);\n// after\nconst s = { fields: [new Field('item', new Utf8(), true)] };\nsanitizeSchema(s);","handlingStrategy":"validation","validationCode":"if (schemaLike != null && typeof schemaLike === 'object' && !('fields' in schemaLike)) {\n  throw new Error('schema-like object must have a `fields` array property');\n}","typeGuard":"function isSchemaLikeObject(v: unknown): v is { fields: unknown[]; metadata?: unknown } {\n  return typeof v === 'object' && v !== null && 'fields' in v;\n}","tryCatchPattern":"try {\n  const schema = sanitizeSchemaWithContext(candidate, ctx);\n} catch (e) {\n  if (e.message.includes(\"no 'fields' property\")) {\n    console.error('Object keys:', Object.keys(candidate));\n  }\n  throw e;\n}","preventionTips":["Use the exact key `fields` (plural) when building schema-like literals","Prefer new Schema(fields) from apache-arrow over hand-built literals","Convert Record<string, DataType> column maps into { fields: [...] } explicitly","Confirm you are passing a schema, not a single field or table"],"tags":["schema","validation","shape","arrow"],"backgroundTag":"schema-validation-failed","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"}