Skip to content

Commit dd6f08a

Browse files
cliffhallclaude
andcommitted
fix(interface-diff): check out the event's SHA; report the CLI's stderr (#4860)
Copilot round 1 on #4975: - Check out github.sha rather than github.ref, so a push run diffs the commit it was triggered for against that event's `before`, not a branch tip a later push moved. - When mcp-server-diff prints no JSON report, include its stderr (where a fatal error goes) in the error, so the reason is not blank. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: cliffhall <cliff@futurescale.com>
1 parent bae0bcb commit dd6f08a

3 files changed

Lines changed: 18 additions & 4 deletions

File tree

‎.github/workflows/everything-mcp-diff.yml‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@ jobs:
8888
# The base is built from history, so all of it is needed, tags
8989
# included (the release base is the previous Release's tag).
9090
fetch-depth: 0
91-
ref: ${{ inputs.target_ref || github.ref }}
91+
# The event's own commit (the merge commit for a PR), not a branch
92+
# ref that a later push could move before this step runs.
93+
ref: ${{ inputs.target_ref || github.sha }}
9294
persist-credentials: false
9395

9496
- uses: actions/setup-node@v7

‎scripts/interface-diff.mjs‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,18 +101,24 @@ export function parseArgs(argv) {
101101
* its exit code cannot tell a change from a broken check; the JSON can.
102102
*
103103
* @param {string} stdout what `mcp-server-diff -o json -q` printed
104+
* @param {string} [stderr] what it printed to stderr: a fatal error before the
105+
* report goes there, so it is the reason when no report came out
104106
* @returns {{ status: "unchanged" | "changed" | "error", error?: string,
105107
* diffs: { endpoint: string, diff: string }[],
106108
* baseCounts?: object, headCounts?: object }}
107109
*/
108-
export function classify(stdout) {
110+
export function classify(stdout, stderr = "") {
109111
let parsed;
110112
try {
111113
parsed = JSON.parse(stdout);
112114
} catch {
113115
return {
114116
status: "error",
115-
error: `mcp-server-diff printed no JSON report:\n${stdout.trim().slice(0, 2000)}`,
117+
error: `mcp-server-diff printed no JSON report:\n${[stderr, stdout]
118+
.map((s) => s.trim())
119+
.filter(Boolean)
120+
.join("\n")
121+
.slice(0, 2000)}`,
116122
diffs: [],
117123
};
118124
}
@@ -321,7 +327,7 @@ export async function main(argv = process.argv.slice(2)) {
321327
{ cwd: repoRoot, encoding: "utf8", maxBuffer: 64 * 1024 * 1024 },
322328
);
323329
if (res.error) throw res.error;
324-
verdict = classify(res.stdout);
330+
verdict = classify(res.stdout, res.stderr);
325331
} catch (err) {
326332
verdict = { status: "error", error: err.message, diffs: [] };
327333
} finally {

‎scripts/interface-diff.test.mjs‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,12 @@ test("output that is not the JSON report is an error, never a pass", () => {
8989
assert.equal(classify(JSON.stringify({ results: [] })).status, "error");
9090
});
9191

92+
test("a CLI crash before the report carries its stderr as the reason", () => {
93+
const v = classify("", "Fatal error: Error: spawn node ENOENT");
94+
assert.equal(v.status, "error");
95+
assert.match(v.error, /no JSON report[\s\S]*spawn node ENOENT/);
96+
});
97+
9298
test("fenceFor outruns any backticks in the content", () => {
9399
assert.equal(fenceFor("plain"), "```");
94100
assert.equal(fenceFor("a ``` b"), "````");

0 commit comments

Comments
 (0)