Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

astro build does not report which file has an invalid frontmatter for MDX files #12352

Closed
1 task done
Princesseuh opened this issue Nov 1, 2024 · 0 comments · Fixed by #12355
Closed
1 task done
Labels
- P3: minor bug An edge case that only affects very specific usage (priority) feat: errors Related to error handling / messages (scope) pkg: mdx Issues pertaining to `@astrojs/mdx` integration

Comments

@Princesseuh
Copy link
Member

Princesseuh commented Nov 1, 2024

Astro Info

Astro                    v4.16.8
Node                     v18.20.3
System                   Linux (x64)
Package Manager          npm
Output                   static
Adapter                  none
Integrations             @astrojs/mdx
                         @astrojs/sitemap

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

N/A

Describe the Bug

In build, for MDX files, a syntax error in the frontmatter does not report the file in which it failed. This works fine for Markdown and Markdoc.

[GenerateContentTypesError] `astro sync` command failed to generate content collection types: can not read a block mapping entry; a multiline key may not be an implicit key
  Hint:
    Check your `src/content/config.*` file for typos.
  Error reference:
    https://docs.astro.build/en/reference/errors/generate-content-types-error/
  Stack trace:
    at new AstroError (file:///home/projects/parigygoyn.github/node_modules/astro/dist/core/errors/errors.js:37:5)
    at async syncInternal (file:///home/projects/parigygoyn.github/node_modules/astro/dist/core/sync/index.js:97:7)
    at async AstroBuilder.run (file:///home/projects/parigygoyn.github/node_modules/astro/dist/core/build/index.js:195:23)
    at async build (file:///home/projects/parigygoyn.github/node_modules/astro/dist/cli/build/index.js:39:3)
    at async cli (file:///home/projects/parigygoyn.github/node_modules/astro/dist/cli/index.js:192:5)
  Caused by:
  can not read a block mapping entry; a multiline key may not be an implicit key
    at generateError (/home/projects/parigygoyn.github/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/loader.js:167:10)
    at readBlockMapping (/home/projects/parigygoyn.github/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/loader.js:1073:9)
    at readDocument (/home/projects/parigygoyn.github/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/loader.js:1525:3)
    at load (/home/projects/parigygoyn.github/node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/loader.js:1614:19)
    at module.exports (/home/projects/parigygoyn.github/node_modules/gray-matter/lib/parse.js:12:17)

What's the expected result?

It reports the file that failed.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-2dp4ww?file=src%2Fcontent%2Fblog%2Fusing-mdx.mdx (make sure to run npm run build, as dev exhibit a different behavior)

Participation

  • I am willing to submit a pull request for this issue.
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Nov 1, 2024
@Princesseuh Princesseuh added - P3: minor bug An edge case that only affects very specific usage (priority) pkg: mdx Issues pertaining to `@astrojs/mdx` integration feat: errors Related to error handling / messages (scope) and removed needs triage Issue needs to be triaged labels Nov 1, 2024
apatel369 added a commit to apatel369/astro that referenced this issue Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P3: minor bug An edge case that only affects very specific usage (priority) feat: errors Related to error handling / messages (scope) pkg: mdx Issues pertaining to `@astrojs/mdx` integration
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant