From 134cf6ba145c9139d38da3478f7aeadaffa8953c Mon Sep 17 00:00:00 2001 From: Dean Harel Date: Sat, 29 Aug 2026 13:45:27 +0300 Subject: [PATCH] fix(publish): say the diff is unavailable rather than claiming no changes The catch around oasdiff wrote "No API-surface changes detected." That branch only runs inside stage === 'changed', which means the spec provably differs from what is published, so a crashed differ produced a permanent public statement that the opposite was true, in both CHANGELOG.md and the release body. Empty oasdiff output and a dead oasdiff are different facts and now read differently; the empty case keeps its wording, which is accurate. The error is also logged rather than swallowed, so the job says why. Verified by running the publisher with oasdiff absent: the log carries "spawnSync oasdiff ENOENT" and the entry reads "Diff unavailable". Not fixed here: this path has never executed in production. CHANGELOG.md holds one entry, "Initial published spec.", which is the no-previous-spec branch, so oasdiff has not run once. UN-7216 carries that. --- scripts/publish.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/scripts/publish.ts b/scripts/publish.ts index ca4f080..76d341c 100644 --- a/scripts/publish.ts +++ b/scripts/publish.ts @@ -100,16 +100,19 @@ async function main(): Promise { if (stage === 'changed') { const tag = releaseTag({ infoVersion: incoming.info.version, isoDate, sha }); // Build a changelog entry by diffing the previous published spec (still on disk) against the - // incoming one, before the overwrite. Best effort: if oasdiff is unavailable or errors, fall back - // to a neutral note rather than fail the publish. + // incoming one, before the overwrite. Best effort: a broken oasdiff must not fail the publish. + // Empty output and a crash are different facts, so they get different text: this branch only runs + // when the spec provably changed, so claiming no changes because the differ died would put a + // false statement into a public changelog and a release body. let diffBody = 'Initial published spec.'; if (fs.existsSync(SPEC_JSON)) { try { diffBody = capture('oasdiff', ['changelog', SPEC_JSON, specPath, '-f', 'markdown']).trim() || 'No API-surface changes detected.'; - } catch { - diffBody = 'No API-surface changes detected.'; + } catch (err) { + console.error(`oasdiff failed, publishing without a diff: ${err instanceof Error ? err.message : err}`); + diffBody = 'Diff unavailable: the spec changed, but oasdiff did not run.'; } } const entry = `## ${tag} (${isoDate.slice(0, 10)})\n\n${diffBody}\n`;