{"record":{"id":"75dc6c2ed1f4be54","repo":"withastro/astro","slug":"actioncalledfromservererror","errorCode":"ActionCalledFromServerError","errorMessage":"Action called from a server-rendered page or endpoint without using `Astro.callAction()`. This wrapper must be used to call actions from server code.","messagePattern":"Action called from a server-rendered page or endpoint without using `Astro\\.callAction\\(\\)`\\. This wrapper must be used to call actions from server code\\.","errorType":"exception","errorClass":"AstroError","httpStatus":null,"severity":"error","filePath":"packages/astro/src/actions/runtime/entrypoints/server.ts","lineNumber":31,"sourceCode":"\tActionClient,\n\tActionErrorCode,\n\tActionInputSchema,\n\tActionReturnType,\n\tSafeResult,\n} from '../types.js';\n\nexport const getActionPath = createGetActionPath({\n\tbaseUrl: import.meta.env.BASE_URL,\n\tshouldAppendTrailingSlash,\n});\n\nexport const actions = createActionsProxy({\n\thandleAction: async (param, path, context) => {\n\t\tconst pipeline: Pipeline | undefined = context\n\t\t\t? Reflect.get(context, pipelineSymbol)\n\t\t\t: undefined;\n\t\tif (!pipeline) {\n\t\t\tthrow new AstroError(ActionCalledFromServerError);\n\t\t}\n\t\tconst action = await pipeline.getAction(path);\n\t\tif (!action) throw new Error(`Action not found: ${path}`);\n\t\treturn action.bind(context)(param);\n\t},\n});\n","sourceCodeStart":13,"sourceCodeEnd":38,"githubUrl":"https://github.com/withastro/astro/blob/d081033d5fe8e8a68c4bbbad4af9d2deb9c74bca/packages/astro/src/actions/runtime/entrypoints/server.ts#L13-L38","documentation":"The server-side actions proxy (createActionsProxy in the server entrypoint) retrieves the rendering Pipeline from the calling context via Reflect.get(context, pipelineSymbol). If that context is not a real Astro.callAction()-provided ActionAPIContext, pipeline is undefined and AstroError ActionCalledFromServerError is thrown. Server action calls must go through Astro.callAction().","triggerScenarios":"Calling actions.myAction(input) directly inside an Astro frontmatter, an API endpoint, or middleware without wrapping it in Astro.callAction(); or invoking the server entrypoint's proxy from outside a request where no pipeline is attached.","commonSituations":"SSR page or endpoint that calls an action synchronously like a normal function; calling an action from onRequest middleware; refactoring client calls onto the server without switching to Astro.callAction().","solutions":["Wrap the call: const result = await Astro.callAction(actions.myAction, input);","Ensure the page/endpoint is server-rendered and that Astro/APIContext is in scope.","For browser calls, use the client actions proxy, not the server entrypoint."],"exampleFix":"// before - src/pages/api/do.astro (frontmatter)\nconst result = await actions.myAction(input);\n// after\nconst result = await Astro.callAction(actions.myAction, input);","handlingStrategy":"validation","validationCode":"// Ensure server calls always go through Astro.callAction by wrapping the actions object.\nfunction callOnServer(astro: { callAction: Function }, actions: Record<string, Function>) {\n  return new Proxy(actions, {\n    get: (_t, name) => (input: unknown) => astro.callAction(actions[name as string], input),\n  });\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["On the server, always use Astro.callAction(actions.x, input).","Never call the server actions proxy from outside a request/Astro context.","Reserve the client proxy for browser code."],"tags":["actions","server","callaction","ssr"],"backgroundTag":null,"analyzedSha":"d081033d5fe8e8a68c4bbbad4af9d2deb9c74bca","analyzedAt":"2026-08-12T13:37:29.035Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}