Skip to content

Commit 361e85a

Browse files
fix(issues): give blank tracker failures a detail and trace issue operations
A tracker error may carry an empty detail, which the wire errors reject. Each issue service operation and the GitHub target helpers now get a named span. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 35f2f6f commit 361e85a

3 files changed

Lines changed: 32 additions & 16 deletions

File tree

‎apps/server/src/issue/IssueService.test.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,8 @@ describe("IssueService", () => {
315315
tracker: GITHUB,
316316
operation: "listIssues",
317317
reason: "failed",
318-
detail: "boom",
318+
// A tracker may fail without a detail; the wire error still needs one.
319+
detail: " ",
319320
});
320321
if (input.scope === "acme/docs")
321322
return { items: [issue("3", "2026-07-04T00:00:00Z")], nextCursor: null };
@@ -349,7 +350,9 @@ describe("IssueService", () => {
349350
result.entries.filter((entry) => entry.projectId === "web").map((entry) => entry.scope),
350351
).toEqual(["Acme/Web", "Acme/Web"]);
351352
expect(result.nextCursors).toEqual({ "github.com Acme/Web": "next" });
352-
expect(result.errors).toEqual([{ projectId: "api", projectTitle: "api", message: "boom" }]);
353+
expect(result.errors).toEqual([
354+
{ projectId: "api", projectTitle: "api", message: "The issue tracker request failed." },
355+
]);
353356
expect(result.viewers).toEqual({ "github.com": "julius" });
354357
expect(result.trackers).toEqual([
355358
expect.objectContaining({ host: "github.com", projectCount: 4, configured: true }),

‎apps/server/src/issue/IssueService.ts‎

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,16 @@ const interactive =
5050
(input: I) =>
5151
call(input).pipe(Effect.provideService(SourceControlRateLimit.Interactive, true));
5252

53+
const traced =
54+
<I, A>(operation: string, call: (input: I) => Effect.Effect<A, IssueError>) =>
55+
(input: I) =>
56+
call(input).pipe(Effect.withSpan(`IssueService.${operation}`));
57+
58+
/** A tracker may fail with no detail; the wire errors carry a non-empty one. */
59+
function trackerDetail(error: IssueTrackerError): string {
60+
return error.detail.trim() || "The issue tracker request failed.";
61+
}
62+
5363
/** One project's resolved tracker: which driver, where it is served from, and its container. */
5464
interface ProjectTrackerBinding {
5565
readonly canonicalKey: string;
@@ -99,7 +109,7 @@ function toIssueError(operation: string): (error: IssueTrackerError) => IssueErr
99109
})
100110
: new IssueOperationError({
101111
operation,
102-
detail: error.detail,
112+
detail: trackerDetail(error),
103113
...(error.reason === "not-found" || error.reason === "rate-limited"
104114
? { reason: error.reason }
105115
: {}),
@@ -311,7 +321,7 @@ const make = Effect.gen(function* () {
311321
errors.push({
312322
projectId: project.project.id,
313323
projectTitle: project.project.title,
314-
message: page.failure.detail,
324+
message: trackerDetail(page.failure),
315325
});
316326
return;
317327
}
@@ -541,15 +551,15 @@ const make = Effect.gen(function* () {
541551

542552
return IssueService.of({
543553
list,
544-
detail,
545-
comments,
546-
templates,
547-
candidates: interactive(candidates),
548-
create: interactive(create),
549-
comment: interactive(comment),
550-
update: interactive(update),
551-
setState: interactive(setState),
552-
react: interactive(react),
554+
detail: traced("detail", detail),
555+
comments: traced("comments", comments),
556+
templates: traced("templates", templates),
557+
candidates: interactive(traced("candidates", candidates)),
558+
create: interactive(traced("create", create)),
559+
comment: interactive(traced("comment", comment)),
560+
update: interactive(traced("update", update)),
561+
setState: interactive(traced("setState", setState)),
562+
react: interactive(traced("react", react)),
553563
});
554564
});
555565

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,15 +142,18 @@ export const make = Effect.gen(function* () {
142142
const notFound = (operation: string) =>
143143
invalid(operation, "GitHub could not find the requested issue.", "not-found");
144144

145-
const repository = Effect.fnUntraced(function* (scope: string, operation: string) {
145+
const repository = Effect.fn("GitHubIssueTracker.repository")(function* (
146+
scope: string,
147+
operation: string,
148+
) {
146149
if (!REPOSITORY.test(scope) || scope.endsWith("/.") || scope.endsWith("/..")) {
147150
return yield* invalid(operation, "A repository was named that GitHub cannot address.");
148151
}
149152
const [owner = "", name = ""] = scope.split("/");
150153
return { owner, name };
151154
});
152155

153-
const issue = Effect.fnUntraced(function* (
156+
const issue = Effect.fn("GitHubIssueTracker.issue")(function* (
154157
input: { readonly scope: string; readonly key: string },
155158
operation: string,
156159
) {
@@ -169,7 +172,7 @@ export const make = Effect.gen(function* () {
169172
) =>
170173
effect.pipe(GitHubGraphQlClient.call({ host, operation }), Effect.mapError(fail(operation)));
171174

172-
const verifiedIssue = Effect.fnUntraced(function* (
175+
const verifiedIssue = Effect.fn("GitHubIssueTracker.verifiedIssue")(function* (
173176
input: { readonly host: string; readonly scope: string; readonly key: string },
174177
operation: string,
175178
) {

0 commit comments

Comments
 (0)