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

Content Loader: Ambiguous error message when required id key is missing from collection entries. #11953

Open
1 task
regisphilibert opened this issue Sep 9, 2024 · 0 comments
Assignees
Labels
- P2: nice to have Not breaking anything but nice to have (priority) feat: content layer Related to the Content Layer feature (scope) feat: errors Related to error handling / messages (scope)

Comments

@regisphilibert
Copy link

Astro Info

Astro                    v4.15.4
Node                     v20.13.0
System                   macOS (arm64)
Package Manager          npm
Output                   hybrid
Adapter                  @astrojs/netlify
Integrations             @astrojs/tailwind

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

No response

Describe the Bug

Currently if entries of a collection declared in the content/config.ts is missing the required id key, Astro throws the following error:

11:31:29 [ERROR] [types] Required
  Stack trace:
    at /Users/username/Boulot/tnd/astro-sanity-project-template/node_modules/zod/lib/index.mjs:587:31
    [...] See full stack trace in the browser, or rerun with --verbose.

Required
  Stack trace:
    at get error [as error] (file:///Users/username/Boulot/tnd/astro-sanity-project-template/node_modules/zod/lib/index.mjs:587:31)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Promise.all (index 3)
    at async ContentLayer.sync (file:///Users/username/Boulot/tnd/astro-sanity-project-template/node_modules/astro/dist/content/content-layer.js:60:7)
    at async AstroBuilder.setup (file:///Users/username/Boulot/tnd/astro-sanity-project-template/node_modules/astro/dist/core/build/index.js:104:5)

As the entries often come from a remote source, TypeScript cannot inform user that the entries are missing the id key. Build error could though.

What's the expected result?

A clear message pointing to the missing key should be provided during the build.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-vostqd-rwqk5v?file=src%2Fcontent%2Fconfig.ts

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 Sep 9, 2024
@Princesseuh Princesseuh added feat: errors Related to error handling / messages (scope) feat: content layer Related to the Content Layer feature (scope) - P2: nice to have Not breaking anything but nice to have (priority) and removed needs triage Issue needs to be triaged labels Sep 11, 2024
@ascorbic ascorbic self-assigned this Sep 19, 2024
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 layer Related to the Content Layer feature (scope) feat: errors Related to error handling / messages (scope)
Projects
None yet
Development

No branches or pull requests

3 participants