Repository navigation
fix(updater): recover Linux .deb/.rpm installs that fail escalation - #12183
Conversation
A `.deb` install fails with `No authentication agent found` when the session has no polkit agent. Orca reported "Quit and reopen Orca, then try again" — wrong advice — and its only action was Retry Download, discarding a verified 160 MB package that was still in the updater cache. Keep the one-click install path, but make a failed root-package install recoverable without downloading again: - Retain the downloaded package and its expected SHA-512 from the `update-downloaded` event, mirroring electron-updater's cache-name rule. - Capture the child stderr that BaseUpdater logs but drops from the `error` event, redact it (ANSI, control bytes, `<home>`, `<package>`, `<user>`, 1 KiB cap), and classify the failure. Classification reads the original text — redaction can rewrite a matched phrase. - Send a structured `linux-package-install` recovery status and render a dedicated card: Copy Install Command / Try Automatic Install Again / Show Package. - Revalidate on every action: cache containment, lstat, streamed SHA-512, timingSafeEqual. Concurrent requests coalesce into one hash pass. - Build the command from fixed tokens plus one POSIX-single-quoted absolute path, resolving sudo and the package manager only from /usr/bin, /bin, /usr/sbin, /sbin. Orca never runs it. - Disable `autoInstallOnAppQuit` for .deb/.rpm so an ordinary quit cannot trigger the same failing escalation after the UI is gone. Extracts the error-card presentation into UpdateErrorCardContent so UpdateCard does not absorb another stateful surface. Lifecycle breadcrumbs carry package type, reason, exit code and version — never a path, command, username or raw child output. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds Linux root-package detection, trusted installation command generation, redacted diagnostics, cached artifact validation, updater recovery state, secure IPC and preload APIs, and web fallbacks. Adds renderer recovery cards with retry, command-copy, package-reveal, release-download, accessibility, localization, and comprehensive test coverage. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/main/updater-events.ts (1)
232-240: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winClear the artifact only after the transient-fallback outcome is known.
clearTrackedLinuxPackageArtifact()runs at Line 234, beforeconsumeMissingManifestPrereleaseFallbackResult()andgetPublishingWindowLastGoodCheck()are read at Lines 235-236. The same handler treats a last-good "not available" as a transient release-transition outcome (Line 243) and keeps the short retry. In that case the retained package is still valid, but it is already destroyed. A background check that lands while a recovery card is shown then leaves the card visible with a missing artifact, and the next action reports "no longer in the update cache".Move the clear after the fallback checks, and skip it for the transient branch.
♻️ Proposed reordering
clearBackgroundCheckLaunchPending() resetMacInstallState() - clearTrackedLinuxPackageArtifact() const missingManifestFallback = consumeMissingManifestPrereleaseFallbackResult() const publishingWindowLastGoodCheck = getPublishingWindowLastGoodCheck() + // Why: a last-good "not available" is a publishing-window blip, not evidence the package is obsolete. + if (!missingManifestFallback && !publishingWindowLastGoodCheck) { + clearTrackedLinuxPackageArtifact() + } const wasUserInitiated = missingManifestFallback?.userInitiated ?? getUserInitiatedCheck()
🧹 Nitpick comments (9)
src/main/updater-linux-package-recovery-actions.test.ts (1)
96-113: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRestore real timers after each test.
beforeEachcallsvi.useFakeTimers(), but no hook restores real timers. A failure that aborts a test leaves the fake clock installed for the remaining tests in this file, which turns one failure into a cascade of timeouts.♻️ Proposed cleanup hook
describe('linux package recovery actions', () => { + afterEach(() => { + vi.useRealTimers() + }) + beforeEach(() => {Add
afterEachto thevitestimport.src/renderer/src/components/LinuxPackageInstallRecoveryCard.test.tsx (1)
105-117: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value
footnoteElementcouples the tests to the DOM nesting depth.The helper walks
document.body.firstElementChild.firstElementChildand then twolastElementChildhops. Any wrapper added insideUpdateErrorCardContentbreaks every footnote assertion with a confusingnull, not with a message about the footnote. Consider querying the footnote by text or by a stabledata-testidon the footnote paragraph instead.src/renderer/src/components/UpdateCard.tsx (1)
529-542: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winForward the full
UpdateErrorCardModelto the shared card.
UpdateErrorCardModelnow declaressecondaryAction,tertiaryAction, andfootnote, but this call site forwards only a subset. No generic error model sets those fields today, so behavior is unchanged. A future model that sets one would silently render nothing. Spreading the model removes that trap.♻️ Proposed simplification
if (errorCard) { return ( - <UpdateErrorCardContent - title={errorCard.title} - summary={errorCard.summary} - explainer={errorCard.explainer} - detail={errorCard.detail} - releaseUrl={errorCard.releaseUrl} - manualLabel={errorCard.manualLabel} - variant={errorCard.variant} - primaryAction={errorCard.primaryAction} - onClose={handleCollapseWithAnimation} - /> + <UpdateErrorCardContent {...errorCard} onClose={handleCollapseWithAnimation} /> ) }src/main/linux-package-install-command.test.ts (2)
96-103: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUnstub the environment in
afterEach.Line 102 calls
vi.unstubAllEnvs()inside the test body. If an assertion on line 100 or 101 fails, the test throws first andPATHstays stubbed for the remaining tests in the file. Move the cleanup to the existingafterEach.♻️ Proposed cleanup move
afterEach(() => { vi.restoreAllMocks() + vi.unstubAllEnvs() })expect(resolveTrustedExecutable('sudo')).toBeNull() expect(statSyncMock).not.toHaveBeenCalledWith('/home/user/.local/bin/sudo') - vi.unstubAllEnvs() })
234-242: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueAssert
result.okbefore matching the command.
result.ok && result.commandevaluates tofalsewhen the build fails, andexpect(false).not.toMatch(...)throws a type error instead of reporting a clear failure. Assertresult.okfirst, then matchresult.command.src/renderer/src/components/UpdateErrorCardContent.tsx (2)
105-113: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueResolve the conflicting size utilities on the close button.
size-7sets a 28px box, andmin-w-[44px] min-h-[44px]then forces 44px. The minimum wins, sosize-7has no effect and the rendered control is 16px larger than the surrounding header expects.-m-2removes only 8px per side. Dropsize-7, or apply the tap-target padding through a wrapper so the visual icon box stays 28px.
164-174: 🩺 Stability & Availability | 🔵 Trivial | 💤 Low valueHandle a rejected
openUrlpromise.
void window.api.shell.openUrl(releaseUrl)discards the promise. If the IPC call rejects, the browser reports an unhandled rejection and the user gets no feedback. Attach acatchand surface the failure through the existingfootnotepath, or at least log it.src/main/window/updater-package-recovery-ipc.test.ts (1)
172-179: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRestore the environment in a teardown hook.
vi.unstubAllEnvs()runs at the end of the test body. If an assertion above it throws, the stubbedELECTRON_RENDERER_URLand thenulltrusted id persist into later tests in the same file. Move the cleanup intoafterEachso it always runs.♻️ Proposed change
+ afterEach(() => { + vi.unstubAllEnvs() + }) + it('rejects a foreign-origin renderer when only the dev URL fallback applies', () => { actualUi.setTrustedUIRendererWebContentsId(null) vi.stubEnv('ELECTRON_RENDERER_URL', 'http://localhost:5173') expectBothChannelsRejected(webContents({ getURL: () => 'http://evil.invalid/index.html' })) - - vi.unstubAllEnvs() })Import
afterEachfromvitest.src/renderer/src/web/web-preload-api.ts (1)
3065-3079: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winCreate the error per rejection.
desktopOnlyErroris oneErrorinstance shared by every rejection from both methods. Its stack points atcreateUpdaterApi, not at the caller, which makes a real failure harder to trace. The instance is also reachable by renderer code, so a mutation ofmessageaffects all later rejections. Build the error inside each method and keep the message in a constant.♻️ Proposed change
- // Why: the linux-package-install recovery status can only originate in the native main process, so - // the web renderer never reaches these branches — reject loudly rather than resolve a fake result. - const desktopOnlyError = new Error( - 'Linux package install recovery is only available in the desktop app.' - ) + // Why: the linux-package-install recovery status can only originate in the native main process, so + // the web renderer never reaches these branches — reject loudly rather than resolve a fake result. + const desktopOnlyMessage = 'Linux package install recovery is only available in the desktop app.' return { @@ - getLinuxPackageInstallInstructions: () => Promise.reject(desktopOnlyError), - showLinuxPackage: () => Promise.reject(desktopOnlyError), + getLinuxPackageInstallInstructions: () => Promise.reject(new Error(desktopOnlyMessage)), + showLinuxPackage: () => Promise.reject(new Error(desktopOnlyMessage)),
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 8364583b-a6a1-4001-948f-cc886c9af5aa
📒 Files selected for processing (31)
config/scripts/electron-builder-config.test.mjssrc/main/linux-package-install-command.test.tssrc/main/linux-package-install-command.tssrc/main/linux-package-install-diagnostic.test.tssrc/main/linux-package-install-diagnostic.tssrc/main/linux-package-update-recovery.test.tssrc/main/linux-package-update-recovery.tssrc/main/linux-update-package-type.test.tssrc/main/linux-update-package-type.tssrc/main/updater-events.test.tssrc/main/updater-events.tssrc/main/updater-fallback.tssrc/main/updater-linux-package-recovery-actions.test.tssrc/main/updater.fallback.test.tssrc/main/updater.test.tssrc/main/updater.tssrc/main/window/attach-main-window-services.tssrc/main/window/updater-package-recovery-ipc.test.tssrc/preload/api-types.tssrc/preload/index.tssrc/preload/renderer-restart-preparation.test.tssrc/preload/updater-package-recovery.test.tssrc/renderer/src/components/LinuxPackageInstallRecoveryCard.test.tsxsrc/renderer/src/components/LinuxPackageInstallRecoveryCard.tsxsrc/renderer/src/components/UpdateCard.error-card.test.tsxsrc/renderer/src/components/UpdateCard.tsxsrc/renderer/src/components/UpdateErrorCardContent.tsxsrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/web/web-preload-api.tssrc/renderer/src/web/web-preload-updater-package-recovery.test.tssrc/shared/types.ts
Greptile SummaryThis PR adds a structured recovery surface for
Confidence Score: 5/5Safe to merge — Linux-only change gated behind the package-type marker file, failing closed at every validation step. Three previous review rounds addressed lifecycle correctness issues. The remaining code is carefully guarded: artifact capture is idempotent, validation is rerun on every action, cache containment correctly handles symlinked parents and path traversal, timing-safe comparison is used for the digest, and IPC handlers enforce sender trust per-invocation. No gaps found in this round. Files Needing Attention: No files require special attention. The manual RC matrix noted in the PR description is the only remaining validation gap and is explicitly called out as outside PR CI scope.
|
| Filename | Overview |
|---|---|
| src/main/linux-package-update-recovery.ts | Core artifact tracking and validation: SHA-512 streaming, lexical + real-path cache containment, in-flight coalescing, and the public instructions/reveal API. All security-relevant paths (containment check, symlink rejection, timing-safe compare) are correctly implemented. |
| src/main/linux-package-install-diagnostic.ts | Logger adapter with redaction pipeline (ANSI+OSC, control chars, home/package/username) and failure classification. Classification correctly reads pre-redaction text; deduplication prevents a later generic exited-with-code-N line from overwriting a specific polkit verdict. |
| src/main/linux-package-install-command.ts | Builds the copy-paste sudo command: executables resolved from trusted directories only via statSync, POSIX single-quoting applied to the path, no shell ever invoked. The invalid-package-path reason is unreachable today but correctly documented. |
| src/main/updater.ts | Major additions: diagnostic capture lifetime, updateInstallCommitted guard preventing false failure reports for a successful Linux install, buildLinuxPackageInstallFailureStatus, and autoInstallOnAppQuit=false for root packages. The synchronous error-event and async catch-block paths are carefully distinguished. |
| src/renderer/src/components/LinuxPackageInstallRecoveryCard.tsx | Recovery card component with three action paths. The pendingAction slot is correctly released via a recovery-watching effect. Clipboard failure keeps the copy path available. mountedRef guards all async state updates. |
| src/main/window/attach-main-window-services.ts | Registers two new IPC handlers behind assertTrustedUpdaterRecoverySender, which checks isTrustedUIRenderer per-invocation against the real predicate — not a mocked stub. |
| src/main/updater-events.ts | Adds captureLinuxPackageArtifact in update-downloaded and clearTrackedLinuxPackageArtifactForOtherVersion in update-available and download-progress. clearTrackedLinuxPackageArtifact in update-not-available correctly clears the artifact when no update is pending. |
| src/main/linux-update-package-type.ts | Reads the package-type marker file from process.resourcesPath and caches the result. pacman is recognized but deliberately excluded from recovery scope; unrecognized markers log a warning rather than defaulting to a guess. |
Reviews (2): Last reviewed commit: "Improve Linux package install recovery d..." | Re-trigger Greptile
- Distinguish invalid-package-path errors from missing package manager - Expand ANSI escape sequence stripping to handle OSC hyperlinks and DCS - Prevent generic error logs from overwriting specific diagnostic verdicts - Add error handling for shell.openUrl in update UI - Fix test isolation with proper afterEach hooks
…tablyai#12183) * fix(updater): recover Linux .deb/.rpm installs that fail escalation A `.deb` install fails with `No authentication agent found` when the session has no polkit agent. Orca reported "Quit and reopen Orca, then try again" — wrong advice — and its only action was Retry Download, discarding a verified 160 MB package that was still in the updater cache. Keep the one-click install path, but make a failed root-package install recoverable without downloading again: - Retain the downloaded package and its expected SHA-512 from the `update-downloaded` event, mirroring electron-updater's cache-name rule. - Capture the child stderr that BaseUpdater logs but drops from the `error` event, redact it (ANSI, control bytes, `<home>`, `<package>`, `<user>`, 1 KiB cap), and classify the failure. Classification reads the original text — redaction can rewrite a matched phrase. - Send a structured `linux-package-install` recovery status and render a dedicated card: Copy Install Command / Try Automatic Install Again / Show Package. - Revalidate on every action: cache containment, lstat, streamed SHA-512, timingSafeEqual. Concurrent requests coalesce into one hash pass. - Build the command from fixed tokens plus one POSIX-single-quoted absolute path, resolving sudo and the package manager only from /usr/bin, /bin, /usr/sbin, /sbin. Orca never runs it. - Disable `autoInstallOnAppQuit` for .deb/.rpm so an ordinary quit cannot trigger the same failing escalation after the UI is gone. Extracts the error-card presentation into UpdateErrorCardContent so UpdateCard does not absorb another stateful surface. Lifecycle breadcrumbs carry package type, reason, exit code and version — never a path, command, username or raw child output. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * Improve Linux package install recovery diagnostics - Distinguish invalid-package-path errors from missing package manager - Expand ANSI escape sequence stripping to handle OSC hyperlinks and DCS - Prevent generic error logs from overwriting specific diagnostic verdicts - Add error handling for shell.openUrl in update UI - Fix test isolation with proper afterEach hooks --------- Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Problem
On the reported machine (
neil-ubuntu,.debinstall, no polkit authentication agent):electron-updater'sBaseUpdaterlogs the child stderr and then throws an error carrying only the command and exit status, so theerrorevent losesNo authentication agent found. Orca surfaced:That advice is wrong for a missing agent, and the card's only action was Retry Download — discarding a verified 161 MB package still sitting in the updater cache.
Approach
Keep the one-click install path (a working polkit agent is unchanged), but make a failed root-package install recoverable without downloading again. Implements
linux-deb-update-polkit-failure-2026-07-30.md.update-downloadedevent, mirroring electron-updater's own cache-name rule. Fails closed on a malformed encoding, an ambiguous file/hash pairing, or a digest that cannot decode.<home>,<package>,<user>, 1 KiB cap) and classified intoauthentication-agent-unavailable/authentication-denied/package-install-failed. Classification reads the original text — redaction can rewrite a matched phrase.lstat, streamed SHA-512,timingSafeEqual. Concurrent requests coalesce into one hash pass.sudoand the package manager resolved only from/usr/bin,/bin,/usr/sbin,/sbin; no-y. Orca never executes it. The copy explicitly says a system terminal on the computer where Orca is installed — an Orca terminal may be on an SSH host or WSL distro..deb/.rpm, which would otherwise fail after the UI is gone.ErrorCardContentis extracted intoUpdateErrorCardContent.tsxsoUpdateCarddoesn't absorb another stateful surface. Nomax-linesdisable added.Trust model
The SHA-512 check is an integrity check against the HTTPS release metadata electron-updater already trusts. It is not a package signature and not a privilege boundary — a same-uid process can still replace the file between validation and paste. The card says so. The load-bearing containment check is the lexical cache-root anchor, which stops a manipulated
update-info.jsonfileNamefrom pointing at/tmpor/dev/shmwhere a different principal could win that race.Review
Three review rounds (8 reviewer passes). Defects found and fixed, most notably:
quitAndInstall()resolves as soon as main schedules the install, so a failed retry never rejects — it arrives later as a status push. The card re-renders rather than remounts, so the busy slot never cleared and every action went inert. Two green tests had asserted the wedged state as correct.aria-disabledremoved the native click block, and the pre-existing HTTP/2 card's "Enable & Restart" had no guard — a double-click fired twoapp.relaunch()calls.Final round: no P0/P1, correctness or security.
Test plan
632 tests across 34 files. Covers the marker matrix, artifact capture/clear boundaries, cache containment (traversal, symlinks, attacker-owned directories), digest validation and coalescing, POSIX quoting, every package-manager command form, trusted-directory discovery with a user-writable
PATHdecoy, redaction/classification, the install-failure lifecycle, IPC sender trust against the realisTrustedUIRenderer, and the card's actions, a11y and keyboard behavior.pnpm run lint, all three typecheck projects, andoxfmt --checkare clean.Not included
--dironly (no marker is emitted); real.deb/.rpmcome fromrelease-cut.yml. Added a config-level test instead, so the marker contract can't silently break. Real packaged assertions belong to a release-pipeline change.pacmanis out of scope per the design (deb/rpmonly) and isn't a shipped target. It would get no recovery card and keepautoInstallOnAppQuit.rpmcommand forms are untested in production —electron-builder.config.cjsships['AppImage', 'deb'], so the Fedora/openSUSE row of the manual matrix can't run against a real Orca rpm.web-preload-api.ts's fallback Proxy answersthen(soawait window.apihangs), and the error card is minimize-only rather than dismissible.Manual verification still needed
Per the design's RC matrix — this cannot be exercised in PR CI:
dbus-run-session/seat-less with no agent: Orca stays usable and the copiedaptcommand installs the retained package.🤖 Generated with Claude Code