different-ai/openwork · error

automation_saved_script_version_not_found

automation_saved_script_version_not_found

Error message

automation_saved_script_version_not_found

What it means

Thrown in validateWorkflowAutomationAction when the ConfigObjectVersionTable lookup for the automation's saved-script version returns no row matching id + configObjectId + organizationId with isDeletedVersion = false. The automation references a script version that does not exist or has been soft-deleted.

Source

Thrown at ee/apps/den-api/src/workflows.ts:576

      eq(ConfigObjectTable.id, ConfigObjectVersionTable.configObjectId),
      eq(ConfigObjectTable.organizationId, organizationId),
      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

View on GitHub (pinned to 2b7df46e8a)

Solutions

  1. Re-point the automation at the latest non-deleted version of the config object.
  2. Create a new version of the script and update the automation's version reference.
  3. Verify the version id belongs to the same organization and config object before saving the automation.

Example fix

// before
action: { configObjectVersionId: deletedVersionId, ... }
// after
const [latest] = await db.select().from(ConfigObjectVersionTable)
  .where(and(eq(ConfigObjectVersionTable.configObjectId, id), eq(ConfigObjectVersionTable.isDeletedVersion, false)))
  .orderBy(desc(ConfigObjectVersionTable.createdAt)).limit(1)
action: { configObjectVersionId: latest.id, ... }
Defensive patterns

Strategy: validation

Validate before calling

const [v] = await db.select({ id: ConfigObjectVersionTable.id }).from(ConfigObjectVersionTable)
  .where(and(eq(ConfigObjectVersionTable.id, versionId),
    eq(ConfigObjectVersionTable.configObjectId, configObjectId),
    eq(ConfigObjectVersionTable.organizationId, organizationId),
    eq(ConfigObjectVersionTable.isDeletedVersion, false))).limit(1)
const versionUsable = !!v

Try / catch

try {
  await updateAutomation({ configObjectVersionId, ... })
} catch (e) {
  if (e.message === "automation_saved_script_version_not_found") {
    // re-point to the latest non-deleted version
  } else throw e
}

Prevention

When it happens

Trigger: Creating/updating an automation pinned to a configObjectVersionId that was deleted, belongs to another config object/org, or never existed (stale id from a pruned version).

Common situations: Deleting/rolling back script versions while an automation still pins the old version id; copying automation config across environments; org migration with dangling version ids.

Related errors


AI-assisted analysis of different-ai/openwork@2b7df46e8a (2026-09-01). Data as JSON: /api/errors/367a3ce1089ed0d9. Report an issue: GitHub.