Astro Info
Astro v7.0.6
Node v24.17.0
System macOS (arm64)
Package Manager pnpm
Output static
Adapter none
Integrations none
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
In Astro v6 and v7, content references are handled inconsistently for entries whose filenames are transformed into different IDs.
Example referenced entry:
src/content/authors/John-Doe.md
Astro's glob loader slugifies the filename and exposes the entry id as:
This means getEntry() expects the slugified id:
await getEntry("authors", "john-doe")
However, a reference value using the original filename casing is still accepted during content validation:
With a schema like:
author: reference("authors")
Astro transforms the reference into:
{
"author": {
"id": "John-Doe",
"collection": "authors"
}
}
This reference then does not resolve, because the actual entry id is john-doe, not John-Doe.
As a result, invalid references can pass validation and produce broken or silently missing output at build time.
What's the expected result?
Astro should handle referenced entry ids consistently with the entry ids produced by content loading.
Either:
- Content validation should reject non-slugified references.
For example, this should fail validation if the actual entry id is john-doe:
Or:
- Astro should apply the same slugification rules when transforming references.
For example:
should be transformed into:
{
"author": {
"id": "john-doe",
"collection": "authors"
}
}
This would make reference() consistent with glob() and getEntry() in Astro v6 and v7.
Link to Minimal Reproducible Example
https://github.com/smn-cds/reproduce-broken-references
Participation
Astro Info
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
In Astro v6 and v7, content references are handled inconsistently for entries whose filenames are transformed into different IDs.
Example referenced entry:
Astro's
globloader slugifies the filename and exposes the entry id as:This means
getEntry()expects the slugified id:However, a reference value using the original filename casing is still accepted during content validation:
{ "author": "John-Doe" }With a schema like:
Astro transforms the reference into:
{ "author": { "id": "John-Doe", "collection": "authors" } }This reference then does not resolve, because the actual entry id is
john-doe, notJohn-Doe.As a result, invalid references can pass validation and produce broken or silently missing output at build time.
What's the expected result?
Astro should handle referenced entry ids consistently with the entry ids produced by content loading.
Either:
For example, this should fail validation if the actual entry id is
john-doe:{ "author": "John-Doe" }Or:
For example:
{ "author": "John-Doe" }should be transformed into:
{ "author": { "id": "john-doe", "collection": "authors" } }This would make
reference()consistent withglob()andgetEntry()in Astro v6 and v7.Link to Minimal Reproducible Example
https://github.com/smn-cds/reproduce-broken-references
Participation