Skip to content

fix: log errors for invalid content config#14350

Merged
ascorbic merged 2 commits intomainfrom
content-config-errors
Sep 15, 2025
Merged

fix: log errors for invalid content config#14350
ascorbic merged 2 commits intomainfrom
content-config-errors

Conversation

@ascorbic
Copy link
Copy Markdown
Contributor

@ascorbic ascorbic commented Sep 12, 2025

Changes

When looking at ways to catch misuse of live collections I realised that currently we're silently ignoring errors when parsing content config. This PR changes it to log errors in these cases. Because these aren't currently fatal errors, throwing would be a breaking change, so I'm just logging for now.

Additionally, if live collections are enabled then it checks if it failed becausecreateLiveCollection has been used in content.config.ts and if so it does throw an error (which was I was originally trying to do).

image

Testing

Docs

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Sep 12, 2025

🦋 Changeset detected

Latest commit: 8d5de1d

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added the pkg: astro Related to the core `astro` package (scope) label Sep 12, 2025
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Sep 12, 2025

CodSpeed Performance Report

Merging #14350 will not alter performance

Comparing content-config-errors (8d5de1d) with main (13f7d36)1

Summary

✅ 6 untouched

Footnotes

  1. No successful run was found on main (c54b11e) during the generation of this report, so 13f7d36 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

Copy link
Copy Markdown
Member

@sarah11918 sarah11918 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a quick changeset thought for your consideration!

(In general, I'll usually suggest starting these with the verb that describes the kind of change to the codebase (adds, improves, refactors), vs what the code in the PR actually does (logs). So just popping in with thoughts if you go in that direction!)

'astro': patch
---

Improves error reporting for content collections by adding logging for configuration errors that had previously been silently ignored. Also adds a new error that is thrown if a live collection is used in `content.config.ts` rather than `live.config.ts`.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sarah11918 how about this?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe "if a live collection is defined in ..." but yes! Love it!

Copy link
Copy Markdown
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we can't test it, could you share a screenshot of the end result?

@ascorbic
Copy link
Copy Markdown
Contributor Author

@ematipico good idea. Added

@ascorbic ascorbic self-assigned this Sep 12, 2025
@ascorbic ascorbic merged commit f59581f into main Sep 15, 2025
37 of 38 checks passed
@ascorbic ascorbic deleted the content-config-errors branch September 15, 2025 08:12
@astrobot-houston astrobot-houston mentioned this pull request Sep 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: astro Related to the core `astro` package (scope)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants