Skip to content

Astro Actions accepting "form" seem broken #14970

@xriter

Description

@xriter

Astro Info

Astro                    v5.16.0
Node                     v24.4.0
System                   macOS (arm64)
Package Manager          bun
Output                   server
Adapter                  @nurodev/astro-bun
Integrations             @astrojs/react
                         @sentry/astro

Describe the Bug

I am not sure from which Astro version this broke, but recently I noticed that actions that use accept: "form" method, don't work anymore. Whereas before this worked fine, after we bumped the astro version recently, now a Server 500 error happens. The Network inspector shows that this is returned:

{
    "type": "AstroActionError",
    "code": "INTERNAL_SERVER_ERROR",
    "status": 500,
    "message": "Right hand side of instanceof is not an object"
}

Below an example code snippet, but there are multiple actions with different input objects that fail.

export const submitReview = defineAction({
    accept: "form",
    input: z.object({
        orderNumber: z.union([z.string(), z.number()]).optional(),
        rating: z.number(),
        text: z.string().optional(),
    }),
    handler: async (data, ctx) => {
...

The only solution I can find right now is to not use accept: "form" at all, and instead manually send the input object to the action.

I remember reading in one of the recent release notes that the Actions stuff was rewritten / redone / improved. Perhaps something then broke?

Note: It's hard to reproduce, because: it works locally in dev mode, it works locally in preview/built mode. It stops working as soon as it is in our live environment. (Happens across different sites though). Could it have anything to do with Cloudflare altering the request body or something?

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs triageIssue needs to be triaged

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions