Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/long-comics-invite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'astro': minor
---

Gives a helpful error message if a user sets `output: "hybrid"` in their Astro config.

The option was removed in Astro 5, but lots of content online still references it, and LLMs often suggest it. It's not always clear that the replacement is `output: "static"`, rather than `output: "server"`. This change adds a helpful error message to guide humans and robots.
8 changes: 6 additions & 2 deletions packages/astro/src/core/config/schemas/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,13 @@ export const AstroConfigSchema = z.object({
.optional()
.default(ASTRO_CONFIG_DEFAULTS.trailingSlash),
output: z
.union([z.literal('static'), z.literal('server')])
.union([z.literal('static'), z.literal('server'), z.literal('hybrid')])
.optional()
.default('static'),
.default('static')
.refine((val): val is 'static' | 'server' => val !== 'hybrid', {
message:
'The `output: "hybrid"` option has been removed. Use `output: "static"` (the default) instead, which now behaves the same way.',
}),
scopedStyleStrategy: z
.union([z.literal('where'), z.literal('class'), z.literal('attribute')])
.optional()
Expand Down
9 changes: 9 additions & 0 deletions packages/astro/test/units/config/config-validate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,15 @@ describe('Config Validation', () => {
);
});

it('errors with helpful message when output is "hybrid"', async () => {
const configError = await validateConfig({ output: 'hybrid' }).catch((err) => err);
assert.equal(configError instanceof z.ZodError, true);
assert.ok(
configError.errors[0].message.includes('removed'),
'Error message should explain that "hybrid" has been removed',
);
});

describe('i18n', async () => {
it('defaultLocale is not in locales', async () => {
const configError = await validateConfig({
Expand Down