{"record":{"id":"6c70fe625a2d44cb","repo":"affaan-m/ECC","slug":"issue-issuenumber-cannot-be-published-review","errorCode":null,"errorMessage":"Issue #${issueNumber} cannot be published: review approval required (current: ${state.review})","messagePattern":"Issue #(.+?) cannot be published: review approval required \\(current: (.+?)\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"scripts/lib/github-coordination/actions.js","lineNumber":206,"sourceCode":"    validations,\n    missingDependencies,\n  };\n}\n\nfunction applyPublish(repo, issueNumber, options = {}, context = {}) {\n  assertValidRepo(repo);\n  assertValidIssueNumber(issueNumber);\n  const policy = context.policy || loadPolicy(context.rootDir || process.cwd(), options.configPath);\n  const issue = getIssue(repo, issueNumber, options);\n  const state = getCoordinationState(issue, policy);\n  const validation = applyValidate(repo, issueNumber, { ...options, dryRun: true }, context, issue);\n\n  if (!validation.ok) {\n    throw new Error(`Issue #${issueNumber} is not ready to publish: ${validation.validations.map(entry => `${entry.check}=${entry.ok}`).join(', ')}`);\n  }\n\n  if (policy.review && policy.review.required && state.review !== 'approved') {\n    throw new Error(`Issue #${issueNumber} cannot be published: review approval required (current: ${state.review})`);\n  }\n\n  const nextState = buildIssueStateFromAction(issue, state, 'publish', {\n    status: 'published',\n    validation: 'passed',\n    review: state.review === 'changes-requested' ? state.review : 'approved',\n    projectState: 'done',\n  }, policy);\n  const trackedIssue = {\n    ...issue,\n    labels: desiredLabelsForState(nextState, policy),\n  };\n\n  if (!options.dryRun) {\n    const body = mergeIssueBody(issue, nextState, policy);\n    editIssue(repo, issueNumber, {\n      body,\n      addLabels: trackedIssue.labels,","sourceCodeStart":188,"sourceCodeEnd":224,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/lib/github-coordination/actions.js#L188-L224","documentation":"applyPublish enforces the review policy: when policy.review.required is true, the issue's coordination state must have review === 'approved' before publishing. Any other review state (pending, changes-requested, unset) blocks publication. The message includes the current review state so the developer knows what must change.","triggerScenarios":"Calling applyPublish with a policy that sets review.required = true while getCoordinationState(issue, policy).review is not 'approved' — e.g. review still 'pending' or 'changes-requested' after a reviewer asked for edits.","commonSituations":"Publishing before any reviewer approved; a reviewer left 'changes-requested' and no re-approval happened after fixes; a repo adopted a review-required policy after issues were authored; CI attempting automated publish without a human review step.","solutions":["Obtain review approval (applyReview with approve) before publishing","If review isn't needed for this issue, update the policy config to review.required = false","Re-request review after addressing 'changes-requested' feedback so the state becomes 'approved'","Check the issue's coordination state (labels/body marker) actually reflects the approval"],"exampleFix":"// before\napplyPublish(repo, 42, {}) // current review: pending\n// after\napplyReview(repo, 42, { action: 'approve' }, ctx);\napplyPublish(repo, 42, {})","handlingStrategy":"try-catch","validationCode":"const state = getCoordinationState(getIssue(repo, n, opts), policy);\nif (policy.review?.required && state.review !== 'approved') throw new Error(`review required, current: ${state.review}`);\napplyPublish(repo, n, opts);","typeGuard":null,"tryCatchPattern":"try { applyPublish(repo, n, opts); } catch (e) { if (String(e.message).includes('review approval required')) { console.error(`request review first; current state parsed from message: ${e.message}`); } throw e; }","preventionTips":["Run applyReview approve before publish when the policy requires review","Check the issue's review label/state before automated publish steps","Re-request review after addressing 'changes-requested' feedback","Keep policy.review.required aligned with your team's actual workflow"],"tags":["github","review","publish-gate"],"backgroundTag":"invalid-state-transition","analyzedSha":"8321021c54d670126ce3b2969d5deb880b4b0c2a","analyzedAt":"2026-09-16T10:08:13.343Z","contentChangedAt":"2026-09-16T10:08:13.343Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}