Skip to content

Commit 758d613

Browse files
fix(source-control): read file-level check annotations
GitHub reports a file-level annotation with start_line 0. Requiring a positive line made the whole failure read for that job fail to decode. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 5542524 commit 758d613

3 files changed

Lines changed: 10 additions & 3 deletions

File tree

‎packages/contracts/src/pullRequest.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,8 @@ export const PullRequestCheckFailure = Schema.Struct({
126126
annotations: Schema.Array(
127127
Schema.Struct({
128128
path: Schema.String.check(Schema.isMaxLength(1024)),
129-
startLine: PositiveInt,
129+
/** 0 for an annotation on the whole file. */
130+
startLine: NonNegativeInt,
130131
level: Schema.Literals(["failure", "warning", "notice"]),
131132
message: Schema.String.check(Schema.isMaxLength(300)),
132133
}),

‎packages/source-control-github/src/server/GitHubRest.test.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,7 @@ describe("GitHub check failures", () => {
360360
if (url.includes("/annotations"))
361361
return json([
362362
{ path: "a.ts", start_line: 4, annotation_level: "failure", message: "bad code" },
363+
{ path: "budget.json", start_line: 0, annotation_level: "failure", message: "grew" },
363364
]);
364365
if (url.endsWith("/logs"))
365366
return new Response(null, {
@@ -376,7 +377,10 @@ describe("GitHub check failures", () => {
376377
expect(result).toMatchObject({
377378
attempt: 1,
378379
failedSteps: ["Run lint"],
379-
annotations: [{ path: "a.ts", startLine: 4, message: "bad code" }],
380+
annotations: [
381+
{ path: "a.ts", startLine: 4, message: "bad code" },
382+
{ path: "budget.json", startLine: 0, message: "grew" },
383+
],
380384
log: { _tag: "excerpt", text: "##[error]bad code", totalLines: 1, truncated: false },
381385
});
382386
expect(result).not.toHaveProperty("required");

‎packages/source-control-github/src/server/gitHubCheckFailures.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {
2+
NonNegativeInt,
23
PositiveInt,
34
type PullRequestCheck,
45
type PullRequestCheckFailure,
@@ -29,7 +30,8 @@ const Job = Schema.Struct({
2930
const Annotations = Schema.Array(
3031
Schema.Struct({
3132
path: Schema.String,
32-
start_line: PositiveInt,
33+
// 0 marks a file-level annotation.
34+
start_line: NonNegativeInt,
3335
annotation_level: Schema.Literals(["failure", "warning", "notice"]),
3436
message: Schema.String,
3537
}),

0 commit comments

Comments
 (0)