{"record":{"id":"0885c1b5fc6495de","repo":"withastro/astro","slug":"collection-loader-for-name-does-not-have-a-load","errorCode":null,"errorMessage":"Collection loader for ${name} does not have a load method","messagePattern":"Collection loader for (.+?) does not have a load method","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/astro/src/content/content-layer.ts","lineNumber":343,"sourceCode":"\t\t\t\t\t\t\t\t_internal: {\n\t\t\t\t\t\t\t\t\trawData: undefined,\n\t\t\t\t\t\t\t\t\tfilePath,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{ ...collection, schema },\n\t\t\t\t\t\t\tfalse,\n\t\t\t\t\t\t),\n\t\t\t\t\tloaderName,\n\t\t\t\t\trefreshContextData: options?.context,\n\t\t\t\t});\n\n\t\t\t\tif ('loader' in collection) {\n\t\t\t\t\tif (typeof collection.loader === 'function') {\n\t\t\t\t\t\treturn simpleLoader(collection.loader as CollectionLoader<{ id: string }>, context);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (!collection.loader?.load) {\n\t\t\t\t\t\tthrow new Error(`Collection loader for ${name} does not have a load method`);\n\t\t\t\t\t}\n\n\t\t\t\t\treturn collection.loader.load(context);\n\t\t\t\t}\n\t\t\t}),\n\t\t);\n\t\tthis.#validateReferences(contentConfig.config.collections, logger);\n\t\tawait fs.mkdir(this.#settings.config.cacheDir, { recursive: true });\n\t\tawait fs.mkdir(this.#settings.dotAstroDir, { recursive: true });\n\t\tconst assetImportsFile = new URL(ASSET_IMPORTS_FILE, this.#settings.dotAstroDir);\n\t\tawait this.#store.writeAssetImports(assetImportsFile);\n\t\tconst modulesImportsFile = new URL(MODULES_IMPORTS_FILE, this.#settings.dotAstroDir);\n\t\tawait this.#store.writeModuleImports(modulesImportsFile);\n\t\tawait this.#store.waitUntilSaveComplete();\n\t\tlogger.info('Synced content');\n\t\tif (this.#settings.config.experimental.contentIntellisense) {\n\t\t\tawait this.regenerateCollectionFileManifest();\n\t\t}","sourceCodeStart":325,"sourceCodeEnd":361,"githubUrl":"https://github.com/withastro/astro/blob/d081033d5fe8e8a68c4bbbad4af9d2deb9c74bca/packages/astro/src/content/content-layer.ts#L325-L361","documentation":"During `sync()`, the content layer iterates collections and, for object-style loaders, calls `collection.loader.load(context)`. If the loader is an object but has no `load` method, the build-time content layer cannot run it and throws. (Function-style loaders are routed to `simpleLoader`; this branch only handles object loaders missing `load`.)","triggerScenarios":"Defining a build-time collection whose `loader` is an object that does not expose a `load` function — typically a live loader accidentally placed in a build-time collection, or a hand-written incomplete loader.","commonSituations":"Passing a live loader (with `loadCollection`/`loadEntry` only) to `defineCollection`; writing a custom loader and forgetting to implement `load`; an integration shipping a loader missing the required method.","solutions":["Use a build-time loader that implements `load` (e.g. `glob()`, `file()`).","If you intend request-time loading, move the collection to `src/live.config.ts` with `defineLiveCollection`.","If writing a custom loader, implement the `load(context)` method."],"exampleFix":"// before\nconst posts = defineCollection({ loader: { name: 'mine' } /* no load */ });\n// after\nimport { glob } from 'astro/loaders';\nconst posts = defineCollection({ loader: glob('src/content/posts/*.md') });","handlingStrategy":"validation","validationCode":"if ('loader' in collection && typeof collection.loader === 'object' && typeof collection.loader.load !== 'function') {\n  throw new Error(`Loader for ${name} needs a load method`);\n}","typeGuard":"function hasLoad(l) { return !!l && typeof l.load === 'function'; }","tryCatchPattern":null,"preventionTips":["Use build-time loaders from `astro/loaders` (`glob`, `file`) for build-time collections.","Ensure custom object loaders implement `load`.","Validate the loader shape in tests before running `astro sync`."],"tags":["content-collections","loader","sync","api-misuse"],"backgroundTag":null,"analyzedSha":"d081033d5fe8e8a68c4bbbad4af9d2deb9c74bca","analyzedAt":"2026-08-12T13:37:29.035Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}