-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Description
Astro Info
Astro v5.16.16
Node v23.11.1
System Linux (x64)
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
(This issue is also present on the main branch as of today.)
Astro prints a warning when getCollection() is invoked for an empty collection. In practice, this warning appears repeatedly during both static builds and when running the dev server. The warning is emitted via console.warn (packages/astro/src/content/runtime.ts:172).
We are developing a loader for custom JSON files supplied by the user. This loader may become publicly available for others to use in the future.
The JSON files can contain data divided into three categories, one of which is optional. We define three collections corresponding to these categories. When data exists for all three categories, no warnings are printed. However, if the optional category is empty or missing, the warning is printed.
These warnings create unnecessary console noise and give the impression that the user has made an error, or that there is a problem with our loader. Currently, there does not appear to be a sanctioned way to suppress these warnings.
We would like a mechanism to either suppress or properly handle warnings for intentionally empty collections, particularly for optional user-supplied data. Additionally, Astro should probably print these warnings only once per run, not once for every processed file.
What's the expected result?
The described warnings are not printed.
Link to Minimal Reproducible Example
https://stackblitz.com/not-relevant
Participation
- I am willing to submit a pull request for this issue.