-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Improve error message for endpoint getStaticPaths with undefined value #6353
Conversation
🦋 Changeset detectedLatest commit: 56d3473 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 |
There will have a compatible problem. |
Ah alright, I see the issue now. Thanks for the write-up! I don't think we can remove support for For endpoints, the problem seems to be that in static generation, we generate files without extensions, which conflict with folder names. I don't think we can add an extension here, that changes how it's served. So I think the solution here is to log an error if |
Thanks for your reply. |
don't we need any tips if meet the |
Your second solution will break a lot of tests, this one cannot be skipped. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes now look good to me! One more pass from docs and we should be good to go.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks so much for everyone's work on this! Signing off on a Docs review, so this PR is in all y'all's hands now! 🙌
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docs LGTM!
Update by bluwy:
Changes
Fixes #6095
Provide a better error message for #6095 as it's not possible to prerender the endpoint with a specific edge case shown in the changeset message. The error looks something like this:
Testing
Test added in Astro's integration tests
Docs
This will create a new Astro error for https://docs.astro.build/en/reference/error-reference/#astro-errors. Appreciate a review!
/cc @withastro/maintainers-docs for feedback!
End of update
Changes
related to #6095
Use the
undefined
to ignore anindex
in the functiongetStaticPaths
when you want to access a website link, such asapi/example/index
.I think there can't appear an
undefined
in the value of returned getStaticPaths.For one, when an
undefined
in the array will break the bundle.such as when config is
And there is an
[...slug].astro
in the directorypages/index
When
[...slug].astro
isResult:
The
page/index/index.html
will replace Index.html.For another:
This situation also happens in the
Endpoints
.It will fight to create the same file of trailing slash each other when the
getStaticPaths
return values of more than one, including anundefined
.this also will cause a bug of #6095.when it is
The path like
api/example
.When the one will create a path as
api/example/one
.When the undefined will create a path as
api/example
.And will get an error:
error EISDIR: illegal operation on a directory, open '/Users/wuls/Desktop/issue/astro-bug-params-undefined/dist/client/api/example'
.Resolution:
My idea is to tell the users uses to replace the
undefined
with theindex
and check the value of returned getStaticPaths.Automating to replace
undefined
withindex
or throwing an error message if there includes anundefined
or send a warn to users.
Such as:
Testing
Docs
https://docs.astro.build/en/reference/configuration-reference/#buildformat