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
3 changes: 1 addition & 2 deletions packages/loopover-miner/lib/discover-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,7 @@ export async function runDiscover(args, options = {}) {
}
return 0;
} catch (error) {
console.error(error instanceof Error ? error.message : String(error));
return 2;
return reportCliFailure(parsed.json, describeCliError(error));
}
}

Expand Down
19 changes: 19 additions & 0 deletions test/unit/miner-discover-cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,25 @@ describe("runDiscover (#4247)", () => {
expect(error).toHaveBeenCalledWith("github_unreachable");
});

it("#5830: --dry-run --json reports fan-out failures as a parseable {ok:false,error} object", async () => {
const initPortfolioQueue = vi.fn();
const fetchCandidateIssuesWithSummary = vi.fn(async () => {
throw new Error("github_unreachable");
});
const log = vi.spyOn(console, "log").mockImplementation(() => undefined);

const exitCode = await runDiscover(["acme/widgets", "--dry-run", "--json"], {
nowMs: NOW,
initPortfolioQueue,
fetchCandidateIssuesWithSummary,
});

expect(exitCode).toBe(2);
expect(initPortfolioQueue).not.toHaveBeenCalled();
const payload = JSON.parse(String(log.mock.calls[0]?.[0]));
expect(payload).toEqual({ ok: false, error: "github_unreachable" });
});

it("#4847: --dry-run stringifies a thrown non-Error value instead of crashing", async () => {
const fetchCandidateIssuesWithSummary = vi.fn(async () => {
throw "raw_string_fault";
Expand Down