different-ai/openwork · error

workflow_matching_test_receipt_required

workflow_matching_test_receipt_required

Error message

workflow_matching_test_receipt_required

What it means

Creating a workflow version requires a recent successful test run as proof: a WorkflowRun finished within RECENT_RUN_WINDOW_MS, produced with the current markdown renderer version, and having both result_markdown and result_digest. Absent or ineligible, creation is refused with this Error so versions are only published from verified runs.

Source

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

    eq(WorkflowRunTable.config_object_id, resource.configObject.id),
    isNull(WorkflowRunTable.config_object_version_id),
    eq(WorkflowRunTable.source, draftReceiptSource(resource.configObject.id, input.draft)),
    eq(WorkflowRunTable.code_digest, codeDigest),
    eq(WorkflowRunTable.script_input_digest, scriptInputDigest),
    inputSchemaDigest === null
      ? isNull(WorkflowRunTable.input_schema_digest)
      : eq(WorkflowRunTable.input_schema_digest, inputSchemaDigest),
    outputSchemaDigest === null
      ? isNull(WorkflowRunTable.output_schema_digest)
      : eq(WorkflowRunTable.output_schema_digest, outputSchemaDigest),
    eq(WorkflowRunTable.status, "succeeded"),
    isNull(WorkflowRunTable.artifact_content_deleted_at),
    gt(WorkflowRunTable.finished_at, new Date(Date.now() - RECENT_RUN_WINDOW_MS)),
  )).limit(1)
  const receipt = receipts[0]
  if (!receipt || receipt.renderer_version !== WORKFLOW_MARKDOWN_RENDERER_VERSION
    || receipt.result_markdown === null || receipt.result_digest === null) {
    throw new Error("workflow_matching_test_receipt_required")
  }

  const consumed = await db.select({ id: ConfigObjectVersionTable.id }).from(ConfigObjectVersionTable).where(and(
    eq(ConfigObjectVersionTable.organizationId, resource.configObject.organizationId),
    eq(ConfigObjectVersionTable.configObjectId, resource.configObject.id),
    eq(ConfigObjectVersionTable.sourceRevisionRef, receipt.id),
  )).limit(1)
  if (consumed[0]) throw new Error("workflow_test_receipt_already_used")

  const built = await input.buildTools()
  const manifestByPath = new Map(built.manifest.flatMap((entry) => [
    [entry.scriptPath, entry] as const,
    [entry.scriptPath.replace(/^tools\./, ""), entry] as const,
  ]))
  for (const required of payload.parsed.requiredCapabilities) {
    const current = manifestByPath.get(required.scriptPath)
    if (!current || current.capabilityName !== required.capabilityName) {
      throw new Error(`workflow_capability_unavailable:${required.scriptPath}`)

View on GitHub (pinned to 2b7df46e8a)

Solutions

  1. Run the workflow's test/matching run successfully, then retry version creation while the run is still recent
  2. If the renderer version changed, re-run the test so the receipt is regenerated with the current renderer
  3. Ensure artifacts are not deleted (result_markdown/result_digest present) before publishing

Example fix

// before
await createWorkflowVersion(ctx, draft) // no recent valid run
// after
const run = await runWorkflowTest(ctx, draft) // finishes with markdown + digest
await createWorkflowVersion(ctx, draft) // receipt from run.id now satisfies the check
Defensive patterns

Strategy: try-catch

Validate before calling

const receipt = recentRuns.find((r) => r.renderer_version === WORKFLOW_MARKDOWN_RENDERER_VERSION && r.result_markdown !== null && r.result_digest !== null)
if (!receipt) throw new Error('Run a successful workflow test with the current renderer before creating a version')

Type guard

function isValidReceipt(r: WorkflowRun | undefined): boolean {
  return Boolean(r && r.renderer_version === WORKFLOW_MARKDOWN_RENDERER_VERSION && r.result_markdown !== null && r.result_digest !== null)
}

Try / catch

try {
  await createWorkflowVersion(ctx, draft)
} catch (e) {
  if (e instanceof Error && e.message === 'workflow_matching_test_receipt_required') {
    // guide user: run the matching test, then publish the version
  } else throw e
}

Prevention

When it happens

Trigger: Creating a version with no recent finished run, or with a run whose renderer_version != WORKFLOW_MARKDOWN_RENDERER_VERSION or whose result_markdown/result_digest is null (deleted artifacts or failed/incomplete run).

Common situations: Developer edits the code and immediately publishes without running a test; artifacts purged (artifact_content_deleted_at set); renderer version bumped making old receipts stale; last test run older than the recency window.

Related errors


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