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/manage-poll.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,7 @@ export async function runManagePoll(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
21 changes: 21 additions & 0 deletions test/unit/miner-manage-poll.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,27 @@ describe("loopover-miner manage poll (#2323/#2325)", () => {
expect(error).toHaveBeenCalledWith("github_404: not found");
});

it("#6054: --dry-run --json reports poll failures as a parseable {ok:false,error} object", async () => {
const initPortfolioQueue = vi.fn();
const initEventLedger = vi.fn();
const pollCheckRuns = vi.fn().mockRejectedValue(new Error("github_404: not found"));
const log = vi.spyOn(console, "log").mockImplementation(() => undefined);

expect(
await runManagePoll(["acme/widgets", "4", "--dry-run", "--json"], {
initPortfolioQueue,
initEventLedger,
pollCheckRuns,
}),
).toBe(2);
expect(initPortfolioQueue).not.toHaveBeenCalled();
expect(initEventLedger).not.toHaveBeenCalled();
expect(JSON.parse(String(log.mock.calls[0]?.[0]))).toEqual({
ok: false,
error: "github_404: not found",
});
});

it("#4847: --dry-run stringifies a thrown non-Error value instead of crashing", async () => {
const pollCheckRuns = vi.fn().mockRejectedValue("raw_string_fault");
const error = vi.spyOn(console, "error").mockImplementation(() => undefined);
Expand Down