Skip to content

astro build fails unexpectedly with build.format set to preserve #17726

Description

@fulstadev

Astro Info

Astro                    v7.2.0
Vite                     v8.2.1
Node                     v26.7.0
System                   macOS (arm64)
Package Manager          npm
Output                   static
Adapter                  none
Integrations             none

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

No response

Describe the Bug

After upgrading astro from version 5.17.1 to version 7.2.0 for a project, I became unable to build astro pages via astro build whose astro files:

  1. sit within /src/pages/[format]/[lang]/
  2. had the following content within their frontmatter:
export async function getStaticPaths() {
  return [
    { params: { format: 'first', lang: 'en' } },
    { params: { format: 'second', lang: 'en' } },
    { params: { format: 'third', lang: 'en' } },
    { params: { format: 'first', lang: 'de' } },
    { params: { format: 'second', lang: 'de' } },
    { params: { format: 'third', lang: 'de' } },
  ];
}

const {format, lang} = Astro.params;

When e.g. trying to astro build the page /src/pages/[format]/[lang]/welcome.astro, I got a build error saying:

first/en/welcome.html13:58:55 [ERROR] TypeError: Missing parameter: format

... indicating that while the path parameter format of the page /src/pages/[format]/[lang]/welcome.astro could be properly resolved, it could not be recognized by the astro build cycle.

After hours of console-logging and seeing that the path parameters are properly resolved and available while the page was being built, I found that the problem was that I set the build.format option in the astro config file to preserve. When uncommenting that, the build succeeded as in version 5.17.1.

I further investigated on this and indeed setting the build.format option to directory (which is the default value hence equivalent of omission tested above) indeed does the trick.

That feels like a bug to me, especially because it did not happen in version 5.17.1; so I wondered if this change is intentional ? If so, it would be very helpful if the SSG docs could e.g. include a note about an incompatibility with the build.format setting.

What's the expected result?

Pages should be generated normally as in version 5.17.1.

In the linked example, try simply changing the value of the build.format config from preserve to directory and vice-versa in the projects' astro.config.mjs file, then re-run npm run build to try to rebuild the project and you will see what I mean.

Link to Minimal Reproducible Example

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

Participation

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    - P4: importantViolate documented behavior or significantly impacts performance (priority)pkg: astroRelated to the core `astro` package (scope)triage: fix pendingReporter needs to verify the triage bot fix works

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions