{"record":{"id":"bb118ebfa3befcbd","repo":"sveltejs/kit","slug":"data-returned-from-action-inside-route-id-is-no-bb118e","errorCode":null,"errorMessage":"Data returned from action inside ${route_id} is not serializable: ${error.message} (data.${error.path})","messagePattern":"Data returned from action inside (.+?) is not serializable: (.+?) \\(data\\.(.+?)\\)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/kit/src/runtime/server/page/actions.js","lineNumber":320,"sourceCode":"\ttry {\n\t\treturn fn(data);\n\t} catch (e) {\n\t\t// If we're here, the data could not be serialized with devalue\n\t\tconst error = /** @type {any} */ (e);\n\n\t\t// if someone tries to use `json()` in their action\n\t\tif (data instanceof Response) {\n\t\t\tthrow new Error(\n\t\t\t\t`Data returned from action inside ${route_id} is not serializable. Form actions need to return plain objects or fail(). E.g. return { success: true } or return fail(400, { message: \"invalid\" });`,\n\t\t\t\t{ cause: e }\n\t\t\t);\n\t\t}\n\n\t\t// if devalue could not serialize a property on the object, etc.\n\t\tif ('path' in error) {\n\t\t\tlet message = `Data returned from action inside ${route_id} is not serializable: ${error.message}`;\n\t\t\tif (error.path !== '') message += ` (data.${error.path})`;\n\t\t\tthrow new Error(message, { cause: e });\n\t\t}\n\n\t\tthrow error;\n\t}\n}\n","sourceCodeStart":302,"sourceCodeEnd":326,"githubUrl":"https://github.com/sveltejs/kit/blob/03f1687fe612ce3d2d9131139b5b188d9cf90c64/packages/kit/src/runtime/server/page/actions.js#L302-L326","documentation":"Devalue failed to serialize a property of the object returned from a form action (or one nested under `fail` data). Because the serialization error carries a `path`, SvelteKit augments the message with the exact offending property (e.g. `data.items.0.date`) so you can fix the returned shape.","triggerScenarios":"Returning values devalue cannot encode from an action: `undefined` in arrays, class instances, functions, `BigInt`, `Symbol`, cyclic references, `Date` inside certain positions, or a promise stored on the returned object.","commonSituations":"Returning ORM entities/Mongoose docs or Prisma objects with methods; returning rows containing `BigInt` IDs; accidental inclusion of functions (e.g. attaching helpers to the result); non-JSON dates or Maps/Sets in older devalue configurations.","solutions":["Map the offending property (see `data.<path>` in the message) to a plain value: `String(bigintValue)`, `.toISOString()` for dates, spread ORM rows into POJOs","Strip functions, class instances, and `undefined` from the returned object","Verify the return type of every branch of your action (including `fail` data)"],"exampleFix":"// before\nexport const actions = {\n  default: async () => {\n    const user = await db.user.findFirst();\n    return { user }; // contains BigInt id\n  }\n};\n// after\nexport const actions = {\n  default: async () => {\n    const user = await db.user.findFirst();\n    return { user: { ...user, id: String(user.id), createdAt: user.createdAt.toISOString() } };\n  }\n};","handlingStrategy":"validation","validationCode":"// sanity check before returning\nconst data = { items };\nJSON.stringify(data); // throws/spot-checks most non-serializable values","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Convert BigInt/Date/Map/Set/class instances to JSON-friendly primitives before returning","Spread ORM results into plain objects; select only needed columns","Read the `data.<path>` in the message to locate the offending field quickly"],"tags":["sveltekit","serialization","devalue","form-actions"],"backgroundTag":"value-not-serializable","analyzedSha":"03f1687fe612ce3d2d9131139b5b188d9cf90c64","analyzedAt":"2026-09-02T02:01:50.504Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}