{"record":{"id":"cd45f556ea772dd3","repo":"withastro/astro","slug":"plugincontentimportserror","errorCode":"PluginContentImportsError","errorMessage":"Unexpected error processing content collection data.","messagePattern":"Unexpected error processing content collection data\\.","errorType":"exception","errorClass":"AstroError","httpStatus":null,"severity":"error","filePath":"packages/astro/src/content/vite-plugin-content-imports.ts","lineNumber":441,"sourceCode":"\t\t\t\treturn `new URL(${JSON.stringify(value.href)})`;\n\t\t\t}\n\n\t\t\t// For Astro assets, add a proxy to track references\n\t\t\tif (typeof value === 'object' && 'ASTRO_ASSET' in value) {\n\t\t\t\tconst { ASTRO_ASSET, ...asset } = value;\n\t\t\t\tasset.fsPath = ASTRO_ASSET;\n\t\t\t\treturn getProxyCode(asset, isSSR);\n\t\t\t}\n\t\t});\n\t} catch (e) {\n\t\tif (e instanceof Error) {\n\t\t\tthrow new AstroError({\n\t\t\t\t...AstroErrorData.UnsupportedConfigTransformError,\n\t\t\t\tmessage: AstroErrorData.UnsupportedConfigTransformError.message(e.message),\n\t\t\t\tstack: e.stack,\n\t\t\t});\n\t\t} else {\n\t\t\tthrow new AstroError({\n\t\t\t\tname: 'PluginContentImportsError',\n\t\t\t\tmessage: 'Unexpected error processing content collection data.',\n\t\t\t});\n\t\t}\n\t}\n}\n","sourceCodeStart":423,"sourceCodeEnd":448,"githubUrl":"https://github.com/withastro/astro/blob/e294953aa8aadd98d5be92e60a03037b05dbdfd4/packages/astro/src/content/vite-plugin-content-imports.ts#L423-L448","documentation":"A catch-all in vite-plugin-content-imports: while stringifying collection data for a generated module, something threw a value that is not an Error instance (for example a string thrown from a custom loader or a getter). Because there is no stack to preserve, Astro wraps it in PluginContentImportsError.","triggerScenarios":"Custom loaders or transforms that throw non-Error values (throw 'bad data'); exotic objects whose getters throw plain strings during serialization.","commonSituations":"Almost always co-occurs with UnsupportedConfigTransformError; third-party loader bugs; defensive throw statements in shared code that raise strings.","solutions":["Run astro build with verbose logging to identify the entry being processed when it throws.","Audit custom loader/transform code for throw statements raising strings or plain objects; always throw new Error(...).","Apply the serialization fixes for UnsupportedConfigTransformError — this error shares the same root cause.","If no custom code is involved, report an Astro issue with the data shape that triggered it."],"exampleFix":"// before (in a custom loader)\nif (!row.id) throw 'row missing id';\n\n// after\nif (!row.id) throw new Error(`row missing id in ${row}`);","handlingStrategy":"try-catch","validationCode":"// Enforce Error-typed throws in your loader code\nfunction assertValid(value, msg) {\n  if (!value) throw new Error(msg); // never throw a bare string\n}","typeGuard":null,"tryCatchPattern":"try {\n  await build();\n} catch (e) {\n  if (e instanceof Error && e.name === 'PluginContentImportsError') {\n    // re-run with verbose logging to find the entry, then audit custom loader throws\n  }\n  throw e;\n}","preventionTips":["Always throw new Error(...) with a message; never throw strings or plain objects.","Keep transform output serializable (see UnsupportedConfigTransformError).","Isolate third-party loaders when this appears to identify which one threw."],"tags":["content-collections","loaders","serialization","internal"],"backgroundTag":"serialization-failed","analyzedSha":"e294953aa8aadd98d5be92e60a03037b05dbdfd4","analyzedAt":"2026-08-18T18:48:03.901Z","contentChangedAt":"2026-08-18T18:48:03.901Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}