different-ai/openwork · error
automation_saved_script_version_invalid
automation_saved_script_version_invalid
Error message
automation_saved_script_version_invalid
What it means
Thrown in validateWorkflowAutomationAction when parseCodemodeScriptPayload fails on the saved version's normalizedPayloadJson. The version row exists but its stored payload is not a valid codemode script payload, so the automation cannot be validated.
Source
Thrown at ee/apps/den-api/src/workflows.ts:578
eq(ConfigObjectTable.objectType, "workflow"),
eq(ConfigObjectTable.status, "active"),
isNull(ConfigObjectTable.deletedAt),
))
.innerJoin(PluginConfigObjectTable, and(
eq(PluginConfigObjectTable.configObjectId, ConfigObjectTable.id),
eq(PluginConfigObjectTable.pluginId, pluginId),
isNull(PluginConfigObjectTable.removedAt),
))
.where(and(
eq(ConfigObjectVersionTable.id, configObjectVersionId),
eq(ConfigObjectVersionTable.configObjectId, configObjectId),
eq(ConfigObjectVersionTable.organizationId, organizationId),
eq(ConfigObjectVersionTable.isDeletedVersion, false),
)).limit(1)
const version = rows[0]?.version
if (!version) throw new Error("automation_saved_script_version_not_found")
const parsed = parseCodemodeScriptPayload(version.normalizedPayloadJson)
if (!parsed.ok) throw new Error("automation_saved_script_version_invalid")
if (parsed.payload.inputSchema) {
const validation = validateCodemodeScriptInput(parsed.payload.inputSchema, input.action.input)
if (!validation.ok) throw new Error("automation_saved_script_input_invalid")
}
}
export async function saveWorkflow(input: {
organizationId: string
ownerMemberId: string
workflow: SaveWorkflowInput
buildTools: () => Promise<BuiltCodemodeTools>
context?: PluginArchActorContext
}): Promise<{ pluginId: string; configObjectId: string; configObjectVersionId: string }> {
const organizationId = normalizeDenTypeId("organization", input.organizationId)
const ownerMemberId = normalizeDenTypeId("member", input.ownerMemberId)
const requestedPluginId = input.workflow.pluginId
? normalizeDenTypeId("plugin", input.workflow.pluginId)
: nullView on GitHub (pinned to 2b7df46e8a)
Solutions
- Create a new version of the script from a valid codemode payload and re-point the automation at it.
- Re-normalize the version payload with the current parser/writer so normalizedPayloadJson is valid.
- Inspect normalizedPayloadJson for corruption and repair or delete the bad version.
Example fix
// before
// automation pinned to a legacy version with non-codemode payload
action: { configObjectVersionId: legacyVersionId }
// after
const v2 = await saveWorkflowVersion({ configObjectId, payload: validCodemodePayload })
action: { configObjectVersionId: v2.id } Defensive patterns
Strategy: validation
Validate before calling
const parsed = parseCodemodeScriptPayload(version.normalizedPayloadJson)
if (!parsed.ok) throw new Error("version payload invalid before automation save") Type guard
const isValidCodemodeVersion = (v: {normalizedPayloadJson: string}) => parseCodemodeScriptPayload(v.normalizedPayloadJson).ok Try / catch
try {
await updateAutomation({ configObjectVersionId, ... })
} catch (e) {
if (e.message === "automation_saved_script_version_invalid") {
// create a fresh valid version and re-point the automation
} else throw e
} Prevention
- Never edit normalizedPayloadJson manually.
- Re-normalize old versions after schema migrations.
- Validate payload parsability in CI for published versions.
When it happens
Trigger: Creating/updating an automation whose referenced version was written by an older schema, corrupted, or written by a different pipeline that does not produce codemode-normalized JSON.
Common situations: Schema/format migrations leaving old versions unparsable; manual DB edits to normalizedPayloadJson; importing versions from another environment with an incompatible format.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- automation_owner_inactive
- automation_saved_script_forbidden
- automation_saved_script_version_not_found
- automation_saved_script_input_invalid
- invalid_session_payload
AI-assisted analysis of different-ai/openwork@2b7df46e8a (2026-09-01).
Data as JSON: /api/errors/4c914cb4bdcb5e9a.
Report an issue: GitHub.