Skip to content

CLI exit code is 0 when command fails on configuration validation Zod error #13994

@Jaanilj

Description

@Jaanilj

Astro Info

Astro                    v5.10.0
Node                     v24.2.0
System                   macOS (arm64)
Package Manager          npm
Output                   static
Adapter                  none
Integrations             @astrojs/sitemap
                         astro-robots-txt
                         astro-icon
                         astro-purgecss
                         astro-html-optimizer
                         @playform/inline
                         @playform/compress

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

Hello,

I've encountered what appears to be an inconsistency in how CLI commands handle configuration validation errors. When a command fails due to a Zod configuration validation error, it returns an exit code of 0 (indicating success) rather than a non-zero error code.

This behavior became problematic in my CI pipeline, which consists of two sequential steps:

  1. Type generation via npx astro sync
  2. ESLint execution with type-dependent rules

During a recent Astro upgrade, my configuration contained an invalid experimental feature (experimental.responsiveImages). While this triggered a configuration validation error in step 1, the successful exit code allowed the pipeline to proceed to step 2, which then failed due to missing type definitions that should have been generated in the previous step.

This created a misleading error trail that significantly complicated debugging, as the root cause (configuration validation failure) was masked by the downstream effects (ESLint failures due to missing types).

While this may be an intentional design choice, it strikes me as potentially unintended behaviour that could benefit from reconsideration.

What's the expected result?

When a CLI command fails due to a Zod configuration validation error, return exit code != 0

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-fv8ukyyk?file=astro.config.mjs

Participation

  • I am willing to submit a pull request for this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs triageIssue needs to be triaged

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions