fix: guard upsertCoordinationWorkItem behind dryRun check in applySync

The store write was unconditional, persisting work items even during dry
runs. Move it inside the !dryRun block alongside editIssue and initialize
snapshot to null beforehand so results.push still receives snapshot: null
for dry runs.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Victor Casado 2026-06-11 15:06:34 -04:00
parent 573ebe0918
commit af0cf0d7c8

View File

@ -104,11 +104,13 @@ function applySync(repo, options = {}, context = {}) {
const body = mergeIssueBody(issue, nextState, policy); const body = mergeIssueBody(issue, nextState, policy);
const labelPlan = syncIssueLabels(repo, issue, nextState, policy, options); const labelPlan = syncIssueLabels(repo, issue, nextState, policy, options);
if (!options.dryRun && normalizeBodyForComparison(body) !== normalizeBodyForComparison(issue.body)) { let snapshot = null;
if (!options.dryRun) {
if (normalizeBodyForComparison(body) !== normalizeBodyForComparison(issue.body)) {
editIssue(repo, issue.number, { body }, options); editIssue(repo, issue.number, { body }, options);
} }
snapshot = upsertCoordinationWorkItem(store, repo, trackedIssue, nextState, 'sync', { ...context, policy });
const snapshot = upsertCoordinationWorkItem(store, repo, trackedIssue, nextState, 'sync', { ...context, policy }); }
results.push({ results.push({
...summarizeStateForOutput(repo, trackedIssue, nextState, 'sync', policy), ...summarizeStateForOutput(repo, trackedIssue, nextState, 'sync', policy),
syncedAt, syncedAt,