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
5 changes: 3 additions & 2 deletions packages/loopover-miner/lib/submission-freshness-check.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion packages/loopover-miner/lib/submission-freshness-check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,9 @@ export async function checkSubmissionFreshness(
const minerLoginKey = minerLogin.toLowerCase();
const referencingPrs = Array.isArray(snapshot.referencingPrs) ? snapshot.referencingPrs : [];
const addressedByAnotherAuthor = referencingPrs.some(
(pr) => typeof pr.authorLogin === "string" && pr.authorLogin.trim().toLowerCase() !== minerLoginKey && (pr.state === "merged" || pr.state === "open"),
(pr) =>
(pr.state === "merged" || pr.state === "open") &&
(typeof pr.authorLogin !== "string" || pr.authorLogin.trim().toLowerCase() !== minerLoginKey),
);
if (addressedByAnotherAuthor) {
return abort(eventLedger, repoFullName, candidate.issueNumber, "already_addressed");
Expand Down
20 changes: 18 additions & 2 deletions test/unit/miner-submission-freshness-check.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,23 @@ describe("checkSubmissionFreshness (#3007)", () => {
expect(result).toEqual({ fresh: false, reason: "already_addressed" });
});

it("a referencing PR with a non-string authorLogin is ignored rather than crashing or false-flagging", async () => {
it("REGRESSION: a merged referencing PR with a missing authorLogin counts as already-addressed (fail-closed)", async () => {
const { claimLedger } = stubClaimLedger([activeClaim]);
const { eventLedger } = stubEventLedger();
const fetchLiveIssueSnapshot = vi.fn(async () => ({
state: "open" as const,
referencingPrs: [{ number: 99, state: "merged" as const, authorLogin: null as unknown as string, createdAt: null }],
}));

const result = await checkSubmissionFreshness(
{ repoFullName: "acme/widgets", issueNumber: 42, minerLogin: "miner-bot" },
{ claimLedger, fetchLiveIssueSnapshot, eventLedger },
);

expect(result).toEqual({ fresh: false, reason: "already_addressed" });
});

it("a referencing PR with a non-string authorLogin counts as already-addressed instead of being ignored", async () => {
const { claimLedger } = stubClaimLedger([activeClaim]);
const { eventLedger } = stubEventLedger();
const fetchLiveIssueSnapshot = vi.fn(async () => ({
Expand All @@ -175,7 +191,7 @@ describe("checkSubmissionFreshness (#3007)", () => {
{ claimLedger, fetchLiveIssueSnapshot, eventLedger },
);

expect(result).toEqual({ fresh: true });
expect(result).toEqual({ fresh: false, reason: "already_addressed" });
});

it("a CLOSED (not merged) referencing PR from another author does not count as already-addressed", async () => {
Expand Down