Skip to content

Commit 08ca0ff

Browse files
refactor(server): pull request errors carry their sentence in message, without a detail getter
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
1 parent c949fc2 commit 08ca0ff

4 files changed

Lines changed: 18 additions & 93 deletions

File tree

‎apps/server/src/pullRequest/GitHubPullRequestCli.test.ts‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ it.effect(
467467
host,
468468
token: Redacted.make(activeToken),
469469
source: "gh" as const,
470-
fingerprint: GitHubCredentials.credentialFingerprint(host, activeToken),
470+
fingerprint: `${host}:${activeToken.length}${activeToken.at(-1)}`,
471471
})),
472472
invalidate: () => Effect.void,
473473
}),
@@ -2567,7 +2567,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
25672567
observedCount: 2,
25682568
limit: 1_000,
25692569
});
2570-
expect(error.detail).toContain("instead of uniquely matching #7");
2570+
expect(error.message).toContain("instead of uniquely matching #7");
25712571
}),
25722572
);
25732573

@@ -2650,7 +2650,7 @@ layer("GitHubPullRequestCli.layer", (it) => {
26502650
observedCount: 1_100,
26512651
limit: 1_000,
26522652
});
2653-
expect(error.detail).toContain("more than 1000 workflow runs");
2653+
expect(error.message).toContain("more than 1000 workflow runs");
26542654
assert.strictEqual(runPages, 11);
26552655
}),
26562656
);
@@ -3484,7 +3484,8 @@ layer("GitHubPullRequestCli.layer", (it) => {
34843484
);
34853485

34863486
assert.strictEqual(error._tag, "GitHubSubjectScopeError");
3487-
expect(error.message).toContain("updateComment");
3487+
if (error._tag === "GitHubSubjectScopeError")
3488+
assert.strictEqual(error.operation, "updateComment");
34883489
// Refused before any mutation was sent.
34893490
assert.strictEqual(mockedExecute.mock.calls.length, 1);
34903491
}),

‎apps/server/src/pullRequest/GitHubPullRequestCli.ts‎

Lines changed: 12 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,8 @@ export class GitHubPullRequestReadError extends Schema.TaggedError<GitHubPullReq
145145
cause: Schema.Defect(),
146146
},
147147
) {
148-
get detail(): string {
149-
return `GitHub CLI returned an unreadable ${this.operation} response.`;
150-
}
151-
152148
override get message(): string {
153-
return `GitHub CLI failed in ${this.operation}: ${this.detail}`;
149+
return `GitHub CLI returned an unreadable ${this.operation} response.`;
154150
}
155151
}
156152

@@ -162,12 +158,8 @@ export class GitHubViewerLoginUnavailableError extends Schema.TaggedError<GitHub
162158
cwd: Schema.String,
163159
},
164160
) {
165-
get detail(): string {
166-
return "GitHub CLI returned no login for the authenticated account.";
167-
}
168-
169161
override get message(): string {
170-
return `GitHub CLI failed in getViewerLogin: ${this.detail}`;
162+
return "GitHub CLI returned no login for the authenticated account.";
171163
}
172164
}
173165

@@ -181,12 +173,8 @@ export class GitHubPullRequestUpdatedAtUnavailableError extends Schema.TaggedErr
181173
number: Schema.Int,
182174
},
183175
) {
184-
get detail(): string {
185-
return `Pull request ${this.repository}#${this.number} reported no update time.`;
186-
}
187-
188176
override get message(): string {
189-
return `GitHub CLI failed in getPullRequestSummary: ${this.detail}`;
177+
return `Pull request ${this.repository}#${this.number} reported no update time.`;
190178
}
191179
}
192180

@@ -198,12 +186,8 @@ export class GitHubDiffCursorError extends Schema.TaggedError<GitHubDiffCursorEr
198186
cwd: Schema.String,
199187
},
200188
) {
201-
get detail(): string {
202-
return "The diff cursor was not one this pull request handed out.";
203-
}
204-
205189
override get message(): string {
206-
return `GitHub CLI failed in getPullRequestDiff: ${this.detail}`;
190+
return "The diff cursor was not one this pull request handed out.";
207191
}
208192
}
209193

@@ -215,12 +199,8 @@ export class GitHubDiffCommitError extends Schema.TaggedError<GitHubDiffCommitEr
215199
cwd: Schema.String,
216200
},
217201
) {
218-
get detail(): string {
219-
return "The named commit was not a commit sha.";
220-
}
221-
222202
override get message(): string {
223-
return `GitHub CLI failed in getPullRequestDiff: ${this.detail}`;
203+
return "The named commit was not a commit sha.";
224204
}
225205
}
226206

@@ -234,15 +214,11 @@ export class GitHubDiffRevisionsUnavailableError extends Schema.TaggedError<GitH
234214
commit: Schema.optional(Schema.String),
235215
},
236216
) {
237-
get detail(): string {
217+
override get message(): string {
238218
return this.commit === undefined
239219
? `Pull request #${this.number} reported no usable base and head revisions.`
240220
: `Commit ${this.commit} reported no usable revisions for this file.`;
241221
}
242-
243-
override get message(): string {
244-
return `GitHub CLI failed in getPullRequestDiffFileContents: ${this.detail}`;
245-
}
246222
}
247223

248224
/** A blob exists, but expanding it would be unsafe or would not produce text. */
@@ -255,15 +231,11 @@ export class GitHubDiffFileContentsUnavailableError extends Schema.TaggedError<G
255231
reason: Schema.Literals(["oversized", "binary"]),
256232
},
257233
) {
258-
get detail(): string {
234+
override get message(): string {
259235
return this.reason === "oversized"
260236
? `The diff file '${this.path}' exceeds the 1 MB expansion limit.`
261237
: `The diff file '${this.path}' is binary.`;
262238
}
263-
264-
override get message(): string {
265-
return `GitHub CLI failed in getPullRequestDiffFileContents: ${this.detail}`;
266-
}
267239
}
268240

269241
/**
@@ -280,12 +252,8 @@ export class GitHubRepositorySelectorError extends Schema.TaggedError<GitHubRepo
280252
operation: Schema.String,
281253
},
282254
) {
283-
get detail(): string {
284-
return "A repository was named that GitHub cannot address.";
285-
}
286-
287255
override get message(): string {
288-
return `GitHub CLI failed in ${this.operation}: ${this.detail}`;
256+
return "A repository was named that GitHub cannot address.";
289257
}
290258
}
291259

@@ -298,12 +266,8 @@ export class GitHubSubjectScopeError extends Schema.TaggedError<GitHubSubjectSco
298266
operation: Schema.String,
299267
},
300268
) {
301-
get detail(): string {
302-
return "The named subject did not belong to the named pull request.";
303-
}
304-
305269
override get message(): string {
306-
return `GitHub CLI failed in ${this.operation}: ${this.detail}`;
270+
return "The named subject did not belong to the named pull request.";
307271
}
308272
}
309273

@@ -319,7 +283,7 @@ export class GitHubWorkflowApprovalRefusedError extends Schema.TaggedError<GitHu
319283
limit: Schema.Int,
320284
},
321285
) {
322-
get detail(): string {
286+
override get message(): string {
323287
if (this.reason === "head-list-truncated") {
324288
return `GitHub returned more than ${this.limit} pull requests for this head branch.`;
325289
}
@@ -328,10 +292,6 @@ export class GitHubWorkflowApprovalRefusedError extends Schema.TaggedError<GitHu
328292
}
329293
return `GitHub returned more than ${this.limit} workflow runs awaiting approval.`;
330294
}
331-
332-
override get message(): string {
333-
return `GitHub CLI refused listWorkflowRunsRequiringApproval: ${this.detail}`;
334-
}
335295
}
336296

337297
/** GitHub omitted the immutable head identity needed to scope an approval safely. */
@@ -343,12 +303,8 @@ export class GitHubWorkflowApprovalHeadUnavailableError extends Schema.TaggedErr
343303
number: Schema.Int,
344304
},
345305
) {
346-
get detail(): string {
347-
return `GitHub did not report a complete head revision for #${this.number}.`;
348-
}
349-
350306
override get message(): string {
351-
return `GitHub CLI refused approve-workflows: ${this.detail}`;
307+
return `GitHub did not report a complete head revision for #${this.number}.`;
352308
}
353309
}
354310

@@ -361,12 +317,8 @@ export class GitHubWorkflowApprovalHeadChangedError extends Schema.TaggedError<G
361317
number: Schema.Int,
362318
},
363319
) {
364-
get detail(): string {
365-
return `The head revision of #${this.number} changed before its workflows could be approved.`;
366-
}
367-
368320
override get message(): string {
369-
return `GitHub CLI refused approve-workflows: ${this.detail}`;
321+
return `The head revision of #${this.number} changed before its workflows could be approved.`;
370322
}
371323
}
372324

‎apps/server/src/pullRequest/GitHubPullRequestProvider.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ export const make = Effect.gen(function* () {
202202
provider: "github",
203203
operation,
204204
...gitHubProviderFailure(error),
205-
detail: error.detail,
205+
detail: error.message,
206206
cause: error,
207207
});
208208

‎apps/server/src/pullRequest/githubStackActions.ts‎

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@ export class GitHubStackChangedError extends Schema.TaggedError<GitHubStackChang
2121
"GitHubStackChangedError",
2222
{ ...stackErrorIdentity, completed: Schema.Int },
2323
) {
24-
get detail(): string {
25-
return this.message;
26-
}
27-
2824
override get message(): string {
2925
return this.completed > 0
3026
? `The stack changed at PR #${this.number} after ${this.completed} layers. Earlier updates remain on GitHub. Refresh it before trying again.`
@@ -36,10 +32,6 @@ export class GitHubStackUnsupportedError extends Schema.TaggedError<GitHubStackU
3632
"GitHubStackUnsupportedError",
3733
stackErrorIdentity,
3834
) {
39-
get detail(): string {
40-
return this.message;
41-
}
42-
4335
override get message(): string {
4436
return "This operation is not supported for this stack.";
4537
}
@@ -49,10 +41,6 @@ export class GitHubStackResponseInvalidError extends Schema.TaggedError<GitHubSt
4941
"GitHubStackResponseInvalidError",
5042
{ ...stackErrorIdentity, cause: Schema.optional(Schema.Defect()) },
5143
) {
52-
get detail(): string {
53-
return this.message;
54-
}
55-
5644
override get message(): string {
5745
return "GitHub returned an unreadable stack operation response.";
5846
}
@@ -62,10 +50,6 @@ export class GitHubStackMergeRejectedError extends Schema.TaggedError<GitHubStac
6250
"GitHubStackMergeRejectedError",
6351
{ ...stackErrorIdentity, cause: Schema.Defect() },
6452
) {
65-
get detail(): string {
66-
return this.message;
67-
}
68-
6953
override get message(): string {
7054
return "GitHub refused the stack merge. Check the stack's branch rules and merge requirements.";
7155
}
@@ -75,10 +59,6 @@ export class GitHubStackMergePendingError extends Schema.TaggedError<GitHubStack
7559
"GitHubStackMergePendingError",
7660
stackErrorIdentity,
7761
) {
78-
get detail(): string {
79-
return this.message;
80-
}
81-
8262
override get message(): string {
8363
return "The merge is still running on GitHub. Check its status there before submitting another request.";
8464
}
@@ -88,10 +68,6 @@ export class GitHubStackPermissionError extends Schema.TaggedError<GitHubStackPe
8868
"GitHubStackPermissionError",
8969
stackErrorIdentity,
9070
) {
91-
get detail(): string {
92-
return this.message;
93-
}
94-
9571
override get message(): string {
9672
return "You cannot update every branch in this stack. Check write access and fork maintainer permissions before retrying.";
9773
}
@@ -101,10 +77,6 @@ export class GitHubStackRebaseFailedError extends Schema.TaggedError<GitHubStack
10177
"GitHubStackRebaseFailedError",
10278
{ ...stackErrorIdentity, completed: Schema.Int, cause: Schema.Defect() },
10379
) {
104-
get detail(): string {
105-
return this.message;
106-
}
107-
10880
override get message(): string {
10981
return `Stack rebase stopped at PR #${this.number} after ${this.completed} layers. Earlier updates remain on GitHub; resolve the failing layer before retrying.`;
11082
}

0 commit comments

Comments
 (0)