Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

fix(updater): read a wrapped server error before scanning its page text

AdityaUmale180b2909e5af
diff --git a/electron/update-errors.mjs b/electron/update-errors.mjs
index 818754c3fa..c25117f09c 100644
--- a/electron/update-errors.mjs
+++ b/electron/update-errors.mjs
@@ -24,14 +24,15 @@ export function updateErrorCode(error) {
const integrity = /ERR_UPDATER_(?:INVALID_SIGNATURE|CHECKSUM_MISMATCH)/i.test(detail);
const tls = /CERT_|ERR_TLS_|UNABLE_TO_VERIFY_LEAF_SIGNATURE|SSL_ERROR|SELF_SIGNED_CERT_IN_CHAIN/i.test(detail);
if (!integrity && tls) return "tls";
+ // The same error wraps a failed GitHub request, such as a 504 while looking up the latest release;
+ // checked before the text scan below, since the server's error page may say anything.
+ if (!integrity && /ERR_UPDATER_INVALID_RELEASE_FEED/.test(detail) && /HttpError: 5\d\d\b/.test(message)) return "network";
// Integrity failures must never be explained away as a network/disk issue.
if (integrity || /checksum|signature|codesign/i.test(detail)) return "integrity";
if (/\bENOSPC\b|no space left|disk (?:is )?full/i.test(detail)) return "disk";
if (/\b(?:EACCES|EPERM)\b|read.only (?:volume|file system)|permission denied|access is denied/i.test(detail)) return "permission";
if (/\bEBUSY\b|being used by another process/i.test(detail)) return "busy";
if (/certificate/i.test(detail)) return "tls";
- // The same error wraps a failed GitHub request, such as a 504 while looking up the latest release.
- if (/ERR_UPDATER_INVALID_RELEASE_FEED/.test(detail) && /HttpError: 5\d\d\b/.test(message)) return "network";
if (/\b404\b|cannot find .*\.yml|cannot parse update info|no files provided|ERR_UPDATER_INVALID_RELEASE_FEED/i.test(detail)) return "feed";
if (/\b(?:ENOTFOUND|ECONNREFUSED|ECONNRESET|ETIMEDOUT|EAI_AGAIN)\b|net::ERR_|\bHTTP[^\n]*\b5\d\d\b|status(?: code)?[: ]+5\d\d\b/i.test(detail)) return "network";
if (message === UPDATE_TEXT.prepareTimeout) return "prepareTimeout";
diff --git a/electron/update-errors.node-test.mjs b/electron/update-errors.node-test.mjs
index 950d176536..f16ebf8b37 100644
--- a/electron/update-errors.node-test.mjs
+++ b/electron/update-errors.node-test.mjs
@@ -43,6 +43,10 @@ test("a server error wrapped with the release feed is a network failure, whateve
);
assert.equal(updateErrorNeedsPerson(error), false);
assert.match(updateErrorMessage(error), /connection and try again/);
+ // the server's own error page may mention a signature too
+ const page = Object.assign(new Error(`Cannot parse releases feed: Error: Unable to find latest version on GitHub: HttpError: 502 Bad Gateway\n"<html>upstream signature check timed out</html>"\nXML:\n${feed}`), { code: "ERR_UPDATER_INVALID_RELEASE_FEED" });
+ assert.equal(updateErrorNeedsPerson(page), false);
+ assert.match(updateErrorMessage(page), /connection and try again/);
const brokenFeed = Object.assign(new Error(`Cannot parse releases feed: TypeError: Cannot read properties of null,\nXML:\n${feed}`), { code: "ERR_UPDATER_INVALID_RELEASE_FEED" });
assert.equal(updateErrorNeedsPerson(brokenFeed), false);
assert.match(updateErrorMessage(brokenFeed), /missing or invalid/);