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

Actions: fix 500 on empty object for Vercel serverless #11634

Merged
merged 3 commits into from
Aug 6, 2024

Conversation

bholmesdev
Copy link
Contributor

Changes

Resolves #11515. We discovered that Actions sets the content-type to application/json even when the body is undefined. We set content-length to 0 for this case, but it seems some deployment platforms (Vercel) may remove this header if it detects an empty body.

This fix removes the content-type when no body is present.

Testing

  • Add test for empty content type
  • Add test for unexpected content type

Docs

N/A

Copy link

changeset-bot bot commented Aug 6, 2024

🦋 Changeset detected

Latest commit: 8460456

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 Aug 6, 2024
@@ -65,15 +65,18 @@ async function handleAction(param, path, context) {
let body = param;
if (!(body instanceof FormData)) {
try {
body = param ? JSON.stringify(param) : undefined;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixes edge case where null is considered an empty body. null is valid JSON!

Copy link
Member

@bluwy bluwy left a comment

Choose a reason for hiding this comment

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

I think it's missing a changeset

@bholmesdev bholmesdev merged commit 2716f52 into main Aug 6, 2024
13 checks passed
@bholmesdev bholmesdev deleted the fix/vercel-empty-action-param branch August 6, 2024 15:54
@astrobot-houston astrobot-houston mentioned this pull request Aug 6, 2024
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.

Astro Actions .safe() function required empty object argument for Vercel deployment
2 participants