Skip to content

Handle failed changelog fetches gracefully and mock changelog in E2E - #23258

Merged
sergiou87 merged 4 commits into
developmentfrom
sergiou87-fix-e2e-update-check-crash
Dec 2, 2026
Merged

sergiou87 merged 4 commits into
developmentfrom
sergiou87-fix-e2e-update-check-crash

Conversation

@sergiou87

Copy link
Copy Markdown
Member

Agent assessment

Self-reported assessment, not an independent review.

Assessed revision: 263d6cefe0ee7a4e2a695a274236058348ce4a40

Dimension Assessment Rationale
Change confidence 8.5/10 ↑ Unit tests in app/test/unit/release-notes-test.ts (15/15) cover HTTP 403, network error, non-array payload, and empty changelog paths.
↑ npm run lint:fix, npm run markdownlint, and TypeScript checks (tsc -p tsconfig.json --noEmit and tsc -p script/tsconfig.json --noEmit) passed.
↓ Full E2E smoke suite was not run locally; CI E2E Smoke jobs will verify packaged macOS and Windows behavior.
Diagnosis confidence 9.5/10 ↑ Direct inspection of app/src/lib/release-notes.ts and app/src/ui/lib/update-store.ts confirms getChangeLog() returns [] on non-OK responses and generateReleaseSummary() unconditionally indexes lastTenReleases[0].
↑ app/app-info.ts only overrode __UPDATES_URL__ for E2E builds, leaving changelog.json hardcoded to live central.github.com.
Evidence fit 9.5/10 ↑ Explains both [e2e:console:error] Failed to load resource: the server responded with a status of 403 () and [e2e:pageerror] TypeError: Cannot read properties of undefined (reading 'notes') in CI runs 46607295614 and 46697645033, which aborted UpdateStore.onUpdateNotAvailable before updating status to UpdateNotAvailable.

Description

Fixes the failing E2E Smoke test (Auto-update › About dialog › shows up-to-date status after no-update check) observed on development in CI runs 46607295614 and 46697645033 on macOS arm64 and Windows x64.

Root cause

  1. E2E builds override __UPDATES_URL__ via DESKTOP_E2E_UPDATES_URL to target the local mock update server, but getChangeLog() in app/src/lib/release-notes.ts hardcoded https://central.github.com/deployments/desktop/desktop/changelog.json. On CI runners, that live request returned HTTP 403.
  2. On a non-OK response, getChangeLog() returned [] (and did not catch fetch or JSON parsing errors). generateReleaseSummary() then called getReleaseSummary(lastTenReleases[0]) with undefined, throwing TypeError: Cannot read properties of undefined (reading 'notes') inside UpdateStore.onUpdateNotAvailable before this.status = UpdateStatus.UpdateNotAvailable could run, leaving #about .update-status stuck on "checking for updates…".

Changes

  • app/src/lib/release-notes.ts:
    • Read the changelog URL from __CHANGELOG_URL__.
    • Catch fetch/JSON errors, log warnings/errors, and validate that the parsed payload is an array in getChangeLog().
    • Return [] early in generateReleaseSummary() and generateDevReleaseSummary() when no releases are available.
  • app/src/ui/lib/update-store.ts & app/src/ui/banners/update-available.tsx:
    • Guard empty newReleases arrays before indexing newReleases[0] in isUpdateShowcase(), renderMessage(), dismissUpdateShowCaseVisibility(), and showReleaseNotes() (falling back to opening the external release notes URL).
  • app/app-info.ts, app/src/lib/globals.d.ts, app/test/globals.mts, app/test/e2e/mock-update-server.ts, docs/technical/e2e-smoke-tests.md:
    • Add build-time __CHANGELOG_URL__ (defaults to https://central.github.com/deployments/desktop/desktop/changelog.json; derives /changelog.json on the mock server when DESKTOP_E2E_UPDATES_URL is set; overridable via DESKTOP_E2E_CHANGELOG_URL).
    • Serve [] from /changelog.json in mock-update-server.ts.
  • app/test/unit/release-notes-test.ts:
    • Add 9 unit tests covering getChangeLog() and generateReleaseSummary() (HTTP 403, network rejection, non-array JSON, empty changelog, fallback to latest release, and newer releases).

Validation (commit 263d6cefe0ee7a4e2a695a274236058348ce4a40)

  • npm test -- app/test/unit/release-notes-test.ts — passed (15/15 tests)
  • npm run lint:fix — passed
  • npm run markdownlint — passed
  • npx tsc -p tsconfig.json --noEmit — passed
  • npx tsc -p script/tsconfig.json --noEmit — passed
  • Gap: Full packaged E2E Smoke suite was not run locally; awaiting CI E2E Smoke verification on macOS arm64 and Windows x64.

Screenshots

N/A — non-visual defensive fix for update-check release notes fetching and E2E mock server support.

Release notes

Notes: [Fixed] Checking for updates no longer gets stuck if fetching release notes fails.

Team-authored review

Evidence: Unit test and lint/typecheck results in the Validation section above (covering commit 263d6cefe0ee7a4e2a695a274236058348ce4a40); visual artifact N/A (no UI layout changes). Pending CI E2E Smoke verification and author confirmation before marking ready.

Review path: Lightweight review (pending author confirmation; note that app/src/ui/lib/update-store.ts and app/app-info.ts are touched, though changes are limited to defensive empty-array guards and E2E changelog URL redirection — escalate to needs-deep-review if the author or reviewer wants extra scrutiny on the updater/build-replacement paths).

In E2E smoke runs, UpdateStore.onUpdateNotAvailable called
generateReleaseSummary(), which fetched the hardcoded
central.github.com changelog.json URL instead of the local mock update
server. When CI runners received HTTP 403, getChangeLog() returned []
and generateReleaseSummary() unconditionally indexed lastTenReleases[0],
throwing a TypeError before UpdateStore could transition to
UpdateNotAvailable.

- Guard against empty changelogs, non-array payloads, and fetch errors
  in getChangeLog(), generateReleaseSummary(), and
  generateDevReleaseSummary()
- Guard empty newReleases arrays in UpdateStore.isUpdateShowcase() and
  UpdateAvailable so empty release summaries fall back safely
- Introduce __CHANGELOG_URL__ in app-info.ts (resolving to
  /changelog.json on the mock update server when
  DESKTOP_E2E_UPDATES_URL is set) and serve /changelog.json from
  mock-update-server.ts
- Add unit tests for getChangeLog() and generateReleaseSummary()
Copilot AI balanced review requested due to automatic review settings December 1, 2026 20:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues block the changelog error-handling and E2E routing changes.

No open issues 🎉

What changed in this PR

This PR prevents changelog fetch failures from interrupting GitHub Desktop’s update checks and redirects E2E release-note requests to the local mock server.

Changes:

  • Handle failed fetches, JSON parsing errors, non-array payloads, and empty changelogs safely.
  • Guard update UI consumers against empty release summaries, with an external release-notes fallback.
  • Add configurable changelog URLs, a mock endpoint, unit coverage, and E2E documentation.
File Description
docs/​technical/​e2e-smoke-tests.md Documents E2E changelog URL routing and overrides.
app/​test/​unit/​release-notes-test.ts Adds fetch-failure, empty-result, and release-selection tests.
app/​test/​globals.mts Defines the changelog URL for unit tests.
app/​test/​e2e/​mock-update-server.ts Serves an empty changelog from the mock server.
app/​src/​ui/​lib/​update-store.ts Skips update showcases when release summaries are empty.
app/​src/​ui/​banners/​update-available.tsx Guards empty summaries and falls back to external release notes.
app/​src/​lib/​release-notes.ts Handles changelog failures and empty results safely.
app/​src/​lib/​globals.d.ts Declares the build-time changelog URL constant.
app/​app-info.ts Configures production and E2E changelog URLs.

Review effort: Balanced

Review feedback: F1 (PR #23258 adversarial review).

When generateDevReleaseSummary() returns an empty array (for example
when changelog fetching fails or returns no releases),
showFakeReleaseNotesPopup() previously still dispatched
PopupType.ReleaseNotes with newReleases: []. Because ReleaseNotes.render()
returns null for an empty list, currentPopup remained set with no visible
dialog to dismiss, leaving modal state stuck active.

This PR introduced that path by making generateDevReleaseSummary()
return [] instead of throwing when no releases are available.

Skip dispatching PopupType.ReleaseNotes when generateDevReleaseSummary()
returns an empty array.

Validation: npx tsc -p tsconfig.json --noEmit and npx eslint --rulesdir eslint-rules app/src/ui/lib/test-ui-components/test-ui-components.ts passed.
Review feedback: F2 (PR #23258 adversarial review).

Returning [] from getChangeLog() on fetch or JSON errors caused
getUserContributions() to return null, which checkIfThankYouIsInOrder()
treated as 'checked, no contributions' and persisted via
updateLastThankYou(). That permanently skipped thanking a contributor
for the current version after a transient network or parse failure.

This PR exacerbated a pre-existing HTTP-error path by also catching
fetch and JSON rejections into the same empty-array return value.

Return null from getChangeLog(), getThankYouByUser(), and
getUserContributions() when changelog retrieval fails, while returning
[] from getUserContributions() when retrieval succeeds with no matching
entries. In checkIfThankYouIsInOrder(), return early without persisting
when userContributions is null and persist only when it is empty.

Validation: npm test -- app/test/unit/release-notes-test.ts (18/18 passed),
npx tsc -p tsconfig.json --noEmit, and eslint on changed files passed.
Review feedback: F3 (PR #23258 adversarial review).

getChangelogURL() previously checked DESKTOP_E2E_CHANGELOG_URL and
DESKTOP_E2E_UPDATES_URL against undefined rather than non-empty strings,
and getChangeLog() constructed new URL(__CHANGELOG_URL__) outside its
try/catch block. An empty or malformed env var could throw at build time
or throw an unhandled TypeError at runtime when fetching release notes.

This PR introduced both getChangelogURL() and __CHANGELOG_URL__.

Trim and require non-empty values for DESKTOP_E2E_CHANGELOG_URL and
DESKTOP_E2E_UPDATES_URL in getChangelogURL(), move URL construction
inside the try/catch block of getChangeLog(), and add a unit test for
an invalid __CHANGELOG_URL__.

Validation: npm test -- app/test/unit/release-notes-test.ts (19/19 passed),
npx tsc -p tsconfig.json --noEmit, npx tsc -p script/tsconfig.json --noEmit,
and npm run lint:fix passed.
@sergiou87
sergiou87 marked this pull request as ready for review December 1, 2026 21:01
@sergiou87
sergiou87 requested a review from a team as a code owner December 1, 2026 21:01
@sergiou87
sergiou87 requested a review from niik December 1, 2026 21:01
@sergiou87
sergiou87 enabled auto-merge December 1, 2026 21:01
@sergiou87
sergiou87 merged commit 72d0351 into development Dec 2, 2026
17 checks passed
@sergiou87
sergiou87 deleted the sergiou87-fix-e2e-update-check-crash branch December 2, 2026 09:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants