{"record":{"id":"cb7f7978384fb0b5","repo":"withastro/astro","slug":"your-loader-s-schema-is-defined-using-a-function","errorCode":null,"errorMessage":"Your loader's schema is defined using a function. This is no longer supported and the schema will be ignored. Please update your loader to use the `createSchema()` utility instead, or report this to the loader author. In a future major version, this will cause the loader to break entirely.","messagePattern":"Your loader's schema is defined using a function\\. This is no longer supported and the schema will be ignored\\. Please update your loader to use the `createSchema\\(\\)` utility instead, or report this to the loader author\\. In a future major version, this will cause the loader to break entirely\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/astro/src/content/utils.ts","lineNumber":88,"sourceCode":"\t\t\t\tz.object({\n\t\t\t\t\ttype: z.literal(CONTENT_LAYER_TYPE),\n\t\t\t\t\tschema: z.any().optional(),\n\t\t\t\t\tloader: z.union([\n\t\t\t\t\t\tz.function(),\n\t\t\t\t\t\tz.object({\n\t\t\t\t\t\t\tname: z.string(),\n\t\t\t\t\t\t\tload: z.function({\n\t\t\t\t\t\t\t\tinput: [z.custom<LoaderContext>()],\n\t\t\t\t\t\t\t\toutput: z.custom<{\n\t\t\t\t\t\t\t\t\tschema?: any;\n\t\t\t\t\t\t\t\t\ttypes?: string;\n\t\t\t\t\t\t\t\t} | void>(),\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\tschema: z\n\t\t\t\t\t\t\t\t.any()\n\t\t\t\t\t\t\t\t.transform((v) => {\n\t\t\t\t\t\t\t\t\tif (typeof v === 'function') {\n\t\t\t\t\t\t\t\t\t\tlogger.warn(\n\t\t\t\t\t\t\t\t\t\t\t'content',\n\t\t\t\t\t\t\t\t\t\t\t`Your loader's schema is defined using a function. This is no longer supported and the schema will be ignored. Please update your loader to use the \\`createSchema()\\` utility instead, or report this to the loader author. In a future major version, this will cause the loader to break entirely.`,\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\treturn v;\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t.superRefine((v, ctx) => {\n\t\t\t\t\t\t\t\t\tif (v !== undefined && !('_zod' in v)) {\n\t\t\t\t\t\t\t\t\t\tctx.addIssue({\n\t\t\t\t\t\t\t\t\t\t\tcode: z.ZodIssueCode.custom,\n\t\t\t\t\t\t\t\t\t\t\tmessage: 'Invalid Zod schema',\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\treturn z.NEVER;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t.optional(),\n\t\t\t\t\t\t\tcreateSchema: z","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/withastro/astro/blob/e294953aa8aadd98d5be92e60a03037b05dbdfd4/packages/astro/src/content/utils.ts#L70-L106","documentation":"The zod validation of your content config detected a loader object whose `schema` is a plain function. The Content Layer API expects schemas as a zod schema object or created via createSchema(); the function form is transformed to undefined and ignored with this deprecation warning, and a future major version will break such loaders entirely.","triggerScenarios":"Writing a custom loader with schema: () => z.object({...}) instead of schema: createSchema((ctx) => z.object({...})); using a third-party loader written against the pre-createSchema API.","commonSituations":"Copy-pasting older examples or blog posts; community loaders (CMS adapters, etc.) not yet updated; upgrading a project across the Astro 4 to 5 boundary where the loader API changed.","solutions":["Import createSchema from 'astro:content' and wrap the schema: schema: createSchema(({ image }) => z.object({...}))","If the loader is third-party, upgrade it or report the warning to its author","Alternatively return a plain zod schema object rather than a function"],"exampleFix":"// before: custom-loader.ts\nexport function myLoader(): Loader {\n  return {\n    name: 'my-loader',\n    load: async ({ store, logger }) => { /* ... */ },\n    schema: () => z.object({ title: z.string() }),\n  };\n}\n\n// after\nimport { createSchema } from 'astro:content';\nexport function myLoader(): Loader {\n  return {\n    name: 'my-loader',\n    load: async ({ store, logger }) => { /* ... */ },\n    schema: createSchema(() => z.object({ title: z.string() })),\n  };\n}","handlingStrategy":"type-guard","validationCode":"// Warn at loader-construction time if a legacy function schema slips in\nfunction assertModernSchema(loader: { schema?: unknown }) {\n  if (typeof loader.schema === 'function') {\n    throw new Error('Loader schema must use createSchema(), not a function');\n  }\n}","typeGuard":"interface ModernLoader { schema?: object; createSchema?: () => Promise<{ schema: object }> }\nfunction usesLegacyFunctionSchema(loader: { schema?: unknown }): loader is { schema: () => unknown } {\n  return typeof loader.schema === 'function';\n}","tryCatchPattern":null,"preventionTips":["Always author loader schemas with createSchema() from 'astro:content'","When adopting a third-party loader, check its changelog for createSchema support","Watch deprecation warnings after major upgrades — they become hard errors in the next major"],"tags":["astro","content-collections","loader","schema","deprecation"],"backgroundTag":"deprecated-api-usage","analyzedSha":"e294953aa8aadd98d5be92e60a03037b05dbdfd4","analyzedAt":"2026-09-09T03:35:40.650Z","contentChangedAt":"2026-09-09T03:35:40.650Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}