Astro Action Naming Bug Report
Astro Info
Astro v5.5.5
Node v22.14.0
System Linux (x64)
Package Manager npm
Output static
Adapter none
Integrations none
Browser-Specific?
No response
Bug Description
Issue Summary
When defining an Astro action with the name apply inside a separate file (e.g., src/actions/testactions.ts), an error occurs. However, defining the same action in src/actions/index.ts works correctly.
This behavior is undocumented and should either be fixed or explicitly mentioned in the documentation.
Steps to Reproduce
-
Create an Astro project.
-
Define actions in src/actions/index.ts:
import { testactions } from "./testactions";
export const server = {
testactions,
};
-
Define the action in src/actions/testactions.ts:
import { defineAction } from "astro:actions";
import { z } from "astro:schema";
export const testactions = {
apply: defineAction({
input: z.object({
message: z.string(),
}),
handler: async (input) => {
return { success: true };
},
}),
};
-
Run the Astro project and observe the error:
[ERROR] Expected handler for action testactions to be a function. Received object.
Additional Context
- This issue does not occur with other action names.
- Renaming
apply to another name (e.g., execute) resolves the problem.
- The documentation does not mention any naming restrictions for actions.
Expected Behavior
- The action should work regardless of the file it is defined in, as long as it is correctly imported and structured.
Actual Behavior
- An error occurs when the action is named
apply and defined outside src/actions/index.ts.
Minimal Reproducible Example
[StackBlitz Demo](https://stackblitz.com/edit/github-z5cktexo)
Participation
Astro Action Naming Bug Report
Astro Info
Browser-Specific?
No response
Bug Description
Issue Summary
When defining an Astro action with the name
applyinside a separate file (e.g.,src/actions/testactions.ts), an error occurs. However, defining the same action insrc/actions/index.tsworks correctly.This behavior is undocumented and should either be fixed or explicitly mentioned in the documentation.
Steps to Reproduce
Create an Astro project.
Define actions in
src/actions/index.ts:Define the action in
src/actions/testactions.ts:Run the Astro project and observe the error:
Additional Context
applyto another name (e.g.,execute) resolves the problem.Expected Behavior
Actual Behavior
applyand defined outsidesrc/actions/index.ts.Minimal Reproducible Example
[StackBlitz Demo](https://stackblitz.com/edit/github-z5cktexo)
Participation