withastro/astro · error · AstroError

PluginContentImportsError

PluginContentImportsError

Error message

Unexpected error processing content collection data.

What it means

A fallback error thrown when the content imports plugin's data processing catches a non-Error value (e.g. a string, number, or null thrown by a third-party library). Since `instanceof Error` is false, the code can't extract a message or stack, so it throws a generic `PluginContentImportsError`. This is distinct from error 109 which handles actual Error instances during the same operation.

Source

Thrown at packages/astro/src/content/vite-plugin-content-imports.ts:440

				return `new URL(${JSON.stringify(value.href)})`;
			}

			// For Astro assets, add a proxy to track references
			if (typeof value === 'object' && 'ASTRO_ASSET' in value) {
				const { ASTRO_ASSET, ...asset } = value;
				asset.fsPath = ASTRO_ASSET;
				return getProxyCode(asset, isSSR);
			}
		});
	} catch (e) {
		if (e instanceof Error) {
			throw new AstroError({
				...AstroErrorData.UnsupportedConfigTransformError,
				message: AstroErrorData.UnsupportedConfigTransformError.message(e.message),
				stack: e.stack,
			});
		} else {
			throw new AstroError({
				name: 'PluginContentImportsError',
				message: 'Unexpected error processing content collection data.',
			});
		}
	}
}

View on GitHub (pinned to d081033d5f)

Solutions

  1. Check the console/dev-server output for any preceding error that may have triggered this.
  2. Review custom loaders, parsers, and transforms for `throw` statements that throw non-Error values — change them to `throw new Error(...)`.
  3. Disable custom integrations one by one to isolate the source.
  4. File an Astro issue if no custom code is involved, including the full build log.

Example fix

// before — custom loader
function myParser(raw) {
  if (!raw) throw 'empty input'; // non-Error throw
  return JSON.parse(raw);
}

// after
function myParser(raw) {
  if (!raw) throw new Error('empty input');
  return JSON.parse(raw);
}
Defensive patterns

Strategy: try-catch

Try / catch

try {
  await processContent();
} catch (e) {
  if (e instanceof Error && e.name === 'PluginContentImportsError') {
    console.error('Unexpected non-Error throw in content pipeline');
  }
  throw e;
}

Prevention

When it happens

Trigger: Code inside the `stringify`/processing pipeline throws a non-Error value (e.g. `throw 'bad value'` or `throw 42`). The catch block's `else` branch fires, creating a plain AstroError with name 'PluginContentImportsError' and message 'Unexpected error processing content collection data.'

Common situations: A third-party content loader or parser throws a non-Error. A custom transform or schema validation function throws a bare string. An internal Astro bug where an assertion fails by throwing a non-Error. A malformed devalue plugin throws a primitive.

Related errors


AI-assisted analysis of withastro/astro@d081033d5f (2026-08-12). Data as JSON: /api/errors/cd45f556ea772dd3. Report an issue: GitHub.