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

Malformed entry filename is not reported #9711

Closed
1 task
florian-lefebvre opened this issue Jan 17, 2024 · 2 comments · Fixed by #9888
Closed
1 task

Malformed entry filename is not reported #9711

florian-lefebvre opened this issue Jan 17, 2024 · 2 comments · Fixed by #9888
Labels
- P2: nice to have Not breaking anything but nice to have (priority) feat: content collections Related to the Content Collections feature (scope) feat: errors Related to error handling / messages (scope)

Comments

@florian-lefebvre
Copy link
Member

Astro Info

Astro                    v4.1.3
Node                     v18.18.0
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?

No response

Describe the Bug

When an entry has an invalid frontmatter, the parsing library throws an error but the associated Astro error is irrelevant: it points to the content/config.* instead of the faulty file. For example, the following mdx file

---
# example.mdx
title: 'Here's a wrong pair'
---

will throw this:

[GenerateContentTypesError] `astro sync` command failed to generate content collection types: can not read an implicit mapping pair; a colon is missed
  Hint:
    Check your `src/content/config.*` file for typos.
  Error reference:
    https://docs.astro.build/en/reference/errors/generate-content-types-error/
  Stack trace:

What's the expected result?

Have a new error that specifies what file is failing. I don't think it's realistic to also want the exact location since it depends on the parsing library

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-se3vcm?file=src%2Fcontent%2Fblog%2Ffirst-post.md

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 Jan 17, 2024
@Princesseuh
Copy link
Member

It doesn't show very well for some reason, but right under the stack trace you have the cause of the error telling you why it happened

@florian-lefebvre
Copy link
Member Author

I don't think the file is specified? So that's for md files. I updated the repro to have the error in the mdx file instead and there are even less indications

@florian-lefebvre florian-lefebvre added - P2: nice to have Not breaking anything but nice to have (priority) feat: errors Related to error handling / messages (scope) feat: content collections Related to the Content Collections feature (scope) and removed needs triage Issue needs to be triaged labels Jan 17, 2024
matthewp pushed a commit that referenced this issue Feb 1, 2024
* fix(#9711): improve `astro sync` error handling

* Update .changeset/healthy-jokes-deny.md

* update unit tests

---------

Co-authored-by: Arsh <69170106+lilnasy@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P2: nice to have Not breaking anything but nice to have (priority) feat: content collections Related to the Content Collections feature (scope) feat: errors Related to error handling / messages (scope)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants