{"record":{"id":"03d7f13f63881a03","repo":"withastro/astro","slug":"expected-server-export-in-actions-file-to-be-an","errorCode":null,"errorMessage":"Expected `server` export in actions file to be an object. Received ${typeof server}.","messagePattern":"Expected `server` export in actions file to be an object\\. Received (.+?)\\.","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/astro/src/core/base-pipeline.ts","lineNumber":371,"sourceCode":"\t}\n\n\tasync getServerIslands(): Promise<ServerIslandMappings> {\n\t\tif (this.serverIslands) {\n\t\t\treturn this.serverIslands();\n\t\t}\n\n\t\treturn {\n\t\t\tserverIslandMap: new Map(),\n\t\t\tserverIslandNameMap: new Map(),\n\t\t};\n\t}\n\n\tasync getAction(path: string): Promise<ActionClient<unknown, ActionAccept, $ZodType>> {\n\t\tconst pathKeys = path.split('.').map((key) => decodeURIComponent(key));\n\t\tlet { server } = await this.getActions();\n\n\t\tif (!server || !(typeof server === 'object')) {\n\t\t\tthrow new TypeError(\n\t\t\t\t`Expected \\`server\\` export in actions file to be an object. Received ${typeof server}.`,\n\t\t\t);\n\t\t}\n\n\t\tfor (const key of pathKeys) {\n\t\t\t// An action is a leaf: once resolved to a function, its own properties\n\t\t\t// are not part of the action namespace and cannot be traversed further.\n\t\t\tif (typeof server === 'function') {\n\t\t\t\tthrow new AstroError({\n\t\t\t\t\t...ActionNotFoundError,\n\t\t\t\t\tmessage: ActionNotFoundError.message(pathKeys.join('.')),\n\t\t\t\t});\n\t\t\t}\n\t\t\tif (FORBIDDEN_PATH_KEYS.has(key)) {\n\t\t\t\tthrow new AstroError({\n\t\t\t\t\t...ActionNotFoundError,\n\t\t\t\t\tmessage: ActionNotFoundError.message(pathKeys.join('.')),\n\t\t\t\t});","sourceCodeStart":353,"sourceCodeEnd":389,"githubUrl":"https://github.com/withastro/astro/blob/d081033d5fe8e8a68c4bbbad4af9d2deb9c74bca/packages/astro/src/core/base-pipeline.ts#L353-L389","documentation":"A `TypeError` thrown when the actions module's `server` export is falsy or not an object. `getAction` calls `this.getActions()` and destructures `{ server }`; if `server` is null, undefined, or a non-object type, the guard `!server || typeof server !== 'object'` triggers. This means the `src/actions/index.*` file doesn't correctly export a `server` object.","triggerScenarios":"The actions file (`src/actions/index.ts`) either doesn't export `server`, exports it as a non-object (function, string, etc.), or the module failed to load and `server` is undefined. `getAction` is called (e.g. via `Astro.callAction` or RPC), destructures `{ server }`, and the typeof check fails.","commonSituations":"The actions file exports actions at the top level instead of nested under `server`. Using the old Actions API format after upgrading. The actions file has a syntax error causing it to export nothing. An integration or custom setup replaces the actions module incorrectly.","solutions":["Ensure `src/actions/index.ts` exports `server` as an object containing action handlers.","Use the `defineActions` or correct export pattern: `export const server = { ... }`.","Check for TypeScript or syntax errors in the actions file.","Verify you're on the correct Astro version for your Actions API usage."],"exampleFix":"// before — src/actions/index.ts\nexport const myAction = async (input) => { ... };\n\n// after\nimport { defineAction } from 'astro:actions';\nexport const server = {\n  myAction: defineAction({\n    input: z.string(),\n    handler: async (input) => { ... },\n  }),\n};","handlingStrategy":"type-guard","validationCode":"import type { server } from './src/actions/index';\n// TypeScript will error if 'server' is missing or wrong type at build time","typeGuard":"function isValidServerExport(server: unknown): server is Record<string, unknown> {\n  return typeof server === 'object' && server !== null && !Array.isArray(server);\n}","tryCatchPattern":null,"preventionTips":["Always use the canonical Actions export pattern: export const server = { ... }.","Run astro check to validate the actions module at type level.","Keep the actions file simple — only export server."],"tags":["actions","actions-module","typeerror","export","server"],"backgroundTag":null,"analyzedSha":"d081033d5fe8e8a68c4bbbad4af9d2deb9c74bca","analyzedAt":"2026-08-12T13:37:29.035Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}