Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions packages/loopover-miner/lib/opportunity-ranker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,22 @@ function normalizeCandidate(candidate: Record<string, unknown>) {
.filter((label) => typeof label === "string" && label.trim())
.map((label) => label.trim())
: [];
// #9330: RankedCandidateIssue's `RawCandidateIssue &` type promises `assignees`, but this function
// dropped it. Mirror `labels`'s array-of-strings validation; no `.trim()` because the producer
// (opportunity-fanout.ts assigneeLogins) already emits clean GitHub logins filtered to length > 0.
const assignees = Array.isArray(candidate.assignees)
? candidate.assignees.filter(
(assignee): assignee is string => typeof assignee === "string" && assignee.length > 0,
)
: [];
return {
owner,
repo,
repoFullName: canonicalRepoFullName,
issueNumber,
title,
labels,
assignees,
commentsCount: Number.isFinite(candidate.commentsCount) ? (candidate.commentsCount as number) : 0,
createdAt: typeof candidate.createdAt === "string" ? candidate.createdAt : null,
updatedAt: typeof candidate.updatedAt === "string" ? candidate.updatedAt : null,
Expand Down
25 changes: 25 additions & 0 deletions test/unit/miner-opportunity-ranker.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,3 +296,28 @@ describe("rankCandidateIssues (#2302 follow-up)", () => {
vi.useRealTimers();
});
});

describe("rankCandidateIssues carries assignees through normalizeCandidate (#9330)", () => {
it("preserves a populated assignees array in the ranked output", () => {
const ranked = rankCandidateIssues(
[rawIssue({ assignees: ["octocat", "hubot"] })],
{ nowMs: NOW },
);
expect(ranked[0]?.assignees).toEqual(["octocat", "hubot"]);
});

it("normalizes a missing or malformed assignees field to [] without throwing", () => {
const ranked = rankCandidateIssues(
[
rawIssue({ issueNumber: 1, assignees: undefined }),
rawIssue({ issueNumber: 2, assignees: "not-an-array" as unknown as string[] }),
rawIssue({ issueNumber: 3, assignees: [42, "", "keep"] as unknown as string[] }),
],
{ nowMs: NOW },
);
const byNumber = new Map(ranked.map((entry) => [entry.issueNumber, entry.assignees]));
expect(byNumber.get(1)).toEqual([]);
expect(byNumber.get(2)).toEqual([]);
expect(byNumber.get(3)).toEqual(["keep"]);
});
});