{"record":{"id":"256ad4dce7f4064b","repo":"different-ai/openwork","slug":"workflow-matching-test-receipt-required","errorCode":"workflow_matching_test_receipt_required","errorMessage":"workflow_matching_test_receipt_required","messagePattern":"workflow_matching_test_receipt_required","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"ee/apps/den-api/src/workflows.ts","lineNumber":402,"sourceCode":"    eq(WorkflowRunTable.config_object_id, resource.configObject.id),\n    isNull(WorkflowRunTable.config_object_version_id),\n    eq(WorkflowRunTable.source, draftReceiptSource(resource.configObject.id, input.draft)),\n    eq(WorkflowRunTable.code_digest, codeDigest),\n    eq(WorkflowRunTable.script_input_digest, scriptInputDigest),\n    inputSchemaDigest === null\n      ? isNull(WorkflowRunTable.input_schema_digest)\n      : eq(WorkflowRunTable.input_schema_digest, inputSchemaDigest),\n    outputSchemaDigest === null\n      ? isNull(WorkflowRunTable.output_schema_digest)\n      : eq(WorkflowRunTable.output_schema_digest, outputSchemaDigest),\n    eq(WorkflowRunTable.status, \"succeeded\"),\n    isNull(WorkflowRunTable.artifact_content_deleted_at),\n    gt(WorkflowRunTable.finished_at, new Date(Date.now() - RECENT_RUN_WINDOW_MS)),\n  )).limit(1)\n  const receipt = receipts[0]\n  if (!receipt || receipt.renderer_version !== WORKFLOW_MARKDOWN_RENDERER_VERSION\n    || receipt.result_markdown === null || receipt.result_digest === null) {\n    throw new Error(\"workflow_matching_test_receipt_required\")\n  }\n\n  const consumed = await db.select({ id: ConfigObjectVersionTable.id }).from(ConfigObjectVersionTable).where(and(\n    eq(ConfigObjectVersionTable.organizationId, resource.configObject.organizationId),\n    eq(ConfigObjectVersionTable.configObjectId, resource.configObject.id),\n    eq(ConfigObjectVersionTable.sourceRevisionRef, receipt.id),\n  )).limit(1)\n  if (consumed[0]) throw new Error(\"workflow_test_receipt_already_used\")\n\n  const built = await input.buildTools()\n  const manifestByPath = new Map(built.manifest.flatMap((entry) => [\n    [entry.scriptPath, entry] as const,\n    [entry.scriptPath.replace(/^tools\\./, \"\"), entry] as const,\n  ]))\n  for (const required of payload.parsed.requiredCapabilities) {\n    const current = manifestByPath.get(required.scriptPath)\n    if (!current || current.capabilityName !== required.capabilityName) {\n      throw new Error(`workflow_capability_unavailable:${required.scriptPath}`)","sourceCodeStart":384,"sourceCodeEnd":420,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/ee/apps/den-api/src/workflows.ts#L384-L420","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Run the workflow's test/matching run successfully, then retry version creation while the run is still recent","If the renderer version changed, re-run the test so the receipt is regenerated with the current renderer","Ensure artifacts are not deleted (result_markdown/result_digest present) before publishing"],"exampleFix":"// before\nawait createWorkflowVersion(ctx, draft) // no recent valid run\n// after\nconst run = await runWorkflowTest(ctx, draft) // finishes with markdown + digest\nawait createWorkflowVersion(ctx, draft) // receipt from run.id now satisfies the check","handlingStrategy":"try-catch","validationCode":"const receipt = recentRuns.find((r) => r.renderer_version === WORKFLOW_MARKDOWN_RENDERER_VERSION && r.result_markdown !== null && r.result_digest !== null)\nif (!receipt) throw new Error('Run a successful workflow test with the current renderer before creating a version')","typeGuard":"function isValidReceipt(r: WorkflowRun | undefined): boolean {\n  return Boolean(r && r.renderer_version === WORKFLOW_MARKDOWN_RENDERER_VERSION && r.result_markdown !== null && r.result_digest !== null)\n}","tryCatchPattern":"try {\n  await createWorkflowVersion(ctx, draft)\n} catch (e) {\n  if (e instanceof Error && e.message === 'workflow_matching_test_receipt_required') {\n    // guide user: run the matching test, then publish the version\n  } else throw e\n}","preventionTips":["Always run the workflow test immediately before publishing a new version","Avoid deleting artifact content for recent runs (artifact_content_deleted_at)","Re-run tests after renderer version bumps so receipts stay current"],"tags":["workflow","test-evidence","receipt","validation"],"backgroundTag":"missing-test-receipt","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}