Compare commits

..

5 Commits

Author SHA1 Message Date
copilot-swe-agent[bot]
e84a65b59d Handle missing backend bug report configuration
Co-authored-by: MasterAcnolo <68693319+MasterAcnolo@users.noreply.github.com>
2026-09-27 18:33:26 +00:00
copilot-swe-agent[bot]
8a11eae28e Initial plan 2026-09-27 18:31:12 +00:00
MasterAcnolo
187e3af559 fix: log transport names files local date 2026-09-27 20:03:25 +02:00
MasterAcnolo
e8c499fe23 fix: sendReport wrong IPC instance 2026-09-27 20:02:56 +02:00
MasterAcnolo
99b7164ff8 fix(update): don't check for update if the app is installed with SNAP or Flatpak 2026-09-27 16:23:28 +02:00
4 changed files with 80 additions and 4 deletions

View File

@@ -122,6 +122,7 @@ function initAutoUpdater(mainWindow) {
* Separated from init for reusability and testability. * Separated from init for reusability and testability.
*/ */
async function checkForUpdates() { async function checkForUpdates() {
if (process.env.SNAP || process.env.FLATPAK_ID) return;
if (!require("electron").app.isPackaged) return; if (!require("electron").app.isPackaged) return;
try { try {

View File

@@ -16,7 +16,12 @@ async function sendReport(params) {
if (includeLogs === "yes" && logDir) { if (includeLogs === "yes" && logDir) {
// YYYY-MM-DD // YYYY-MM-DD
const today = new Date().toISOString().split("T")[0]; const now = new Date();
const today = [
now.getFullYear(),
String(now.getMonth() + 1).padStart(2, "0"),
String(now.getDate()).padStart(2, "0")
].join("-");
const logFilePath = path.join(logDir, `LOGS-${today}.log`); const logFilePath = path.join(logDir, `LOGS-${today}.log`);
@@ -30,10 +35,17 @@ async function sendReport(params) {
} }
} }
const response = await fetch(process.env.BUG_REPORT_URL, { const reportUrl = process.env.BUG_REPORT_URL;
const reportApiKey = process.env.BUG_REPORT_API_KEY;
if (!reportUrl || !reportApiKey) {
throw new Error("Bug report service is not configured. Missing BUG_REPORT_URL or BUG_REPORT_API_KEY on backend.");
}
const response = await fetch(reportUrl, {
method: "POST", method: "POST",
headers: { headers: {
"X-Api-Key": process.env.BUG_REPORT_API_KEY "X-Api-Key": reportApiKey
}, },
body: formData body: formData
}); });

View File

@@ -76,7 +76,7 @@ class BugReportModal {
window.electronAPI.logInfo("Submitting:", data); window.electronAPI.logInfo("Submitting:", data);
try { try {
const success = await window.electronAPI.sendReport(data); const success = await window.topbarAPI.sendReport(data);
if (success) { if (success) {
localStorage.removeItem("draft_bug_title"); localStorage.removeItem("draft_bug_title");

View File

@@ -0,0 +1,63 @@
jest.mock("../../server/logger", () => ({
logger: {
info: jest.fn(),
warn: jest.fn(),
error: jest.fn(),
},
logDir: null,
}));
const { sendReport } = require("../../app/sendReport");
describe("sendReport", () => {
const originalEnv = { ...process.env };
beforeEach(() => {
jest.clearAllMocks();
process.env.BUG_REPORT_URL = "";
process.env.BUG_REPORT_API_KEY = "";
global.fetch = jest.fn();
});
afterAll(() => {
process.env = originalEnv;
});
test("throws a clear error when backend bug report config is missing", async () => {
await expect(
sendReport({
title: "Bug title",
description: "Bug description",
includeLogs: "no",
}),
).rejects.toThrow(
"Bug report service is not configured. Missing BUG_REPORT_URL or BUG_REPORT_API_KEY on backend.",
);
expect(global.fetch).not.toHaveBeenCalled();
});
test("sends request from backend when bug report config is present", async () => {
process.env.BUG_REPORT_URL = "https://example.com/report";
process.env.BUG_REPORT_API_KEY = "safe-test-key";
global.fetch.mockResolvedValue({ ok: true });
await expect(
sendReport({
title: "Bug title",
description: "Bug description",
includeLogs: "no",
}),
).resolves.toBe(true);
expect(global.fetch).toHaveBeenCalledWith(
"https://example.com/report",
expect.objectContaining({
method: "POST",
headers: {
"X-Api-Key": "safe-test-key",
},
}),
);
});
});