Repository navigation
fix: harden supported-versions validation, recovery, and exception scoping - #3407
Conversation
WalkthroughSupported-version validation now handles scoped payload sources, malformed fallback data, persisted identities, and resume refreshes. Server reducers avoid creating unknown entries. Unsupported-server UI adds a check-again action, and the dialog rechecks when the selected server changes. ChangesSupported-version and server state updates
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant User
participant UnsupportedServer
participant ipcRenderer
participant checkSupportedVersionServers
participant updateSupportedVersionsData
User->>UnsupportedServer: click check again
UnsupportedServer->>ipcRenderer: invoke refresh-supported-versions with serverUrl
ipcRenderer->>checkSupportedVersionServers: refresh selected server
checkSupportedVersionServers->>updateSupportedVersionsData: update support data
updateSupportedVersionsData-->>UnsupportedServer: updated supported-version state
Possibly related PRs
Suggested labels: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
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 |
Audited the supported-versions subsystem end to end after the
uniqueId-scope escalation and fixed the confirmed defects:
- Wrap the cache/builtin fallback validation in a helper with try/catch
so a malformed cached payload can no longer reject the update before
the error state is dispatched, which left fetchState stuck at
'loading' and suppressed the UnsupportedServer block gate.
- Catch rejections at all four fire-and-forget validation call sites.
- Fall back to the persisted workspace uniqueID when the fresh fetch
fails so the cloud lookup is not skipped for previously-known servers.
- Switch uniqueID/version/gitCommitHash reducer cases from upsert to
update so a late identity dispatch cannot resurrect a server deleted
while a validation was in flight.
- Guard getExpirationMessageTranslated against payloads whose i18n
dictionary lacks both the user language and 'en'; the missing guard
crashed the async check and silently suppressed the expiring-
workspace warning dialog.
- Revalidate all servers on powerMonitor 'resume' (the window 'online'
event does not fire when waking with the same network connected).
- Use the real currentView state in SupportedVersionDialog's effect
dependencies; the previous dependency was the imported reducer
function, which never changes, so the dialog never re-checked on
view switches.
- Add a 'Check again' button to the unsupported-workspace screen so
users can re-trigger validation without restarting the app.
- Fix logRequestError printing a literal ${description}.
Also relax the exception scope check for UNKNOWN local identity: an
unfetchable workspace uniqueID (e.g. settings.public restricted by
enterprise API ACLs) no longer disqualifies a domain-matched exception;
a PROVEN uniqueID mismatch still rejects. The gate is client-side UX
enforcement rather than a security boundary, and wrongly blocking a
legitimate workspace is the worse failure mode.
Server, cloud, and cache supported-versions payloads are fetched from or for the server being validated, so their exceptions block cannot belong to another tenant. For these sources a domain/uniqueId scope mismatch is now logged as a diagnostic warning instead of disqualifying the exception. The bundled builtin payload is the only source that could carry another deployment's exceptions and keeps the strict scope requirement. This removes the remaining paths where a valid, unexpired exception could be rejected over unverifiable or drifted identity data (restricted settings.public API, rotated workspace uniqueID, stale persisted state).
A missing or unparseable enforcementStartDate previously produced an Invalid Date that failed the future-date comparison and fell through to the unsupported verdict — blocking the workspace based on incomplete payload data. Blocking now requires a valid, past enforcement date: uncertain data keeps the server usable until a payload with a valid enforcement date proves enforcement is active.
92b3e1b to
c3231e7
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/ui/components/SupportedVersionDialog/index.tsx (1)
86-90: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick winPass
supportedVersionsSourceinto both revalidation calls.isServerVersionSupportednow treatspayloadSource: 'builtin'strictly, but these calls fall back to the permissive path. Cached builtin payloads can then be re-evaluated differently from the initialupdateSupportedVersionsDataverdict.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/ui/components/SupportedVersionDialog/index.tsx` around lines 86 - 90, Update both revalidation calls in SupportedVersionDialog, including the call containing isServerVersionSupported, to pass the server’s supportedVersionsSource as the payloadSource argument. Ensure every invocation uses the same source value used by updateSupportedVersionsData so cached builtin payloads follow the strict validation path.
🧹 Nitpick comments (2)
src/servers/supportedVersions/main.main.spec.ts (1)
2586-2598: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winConsider also asserting the resume-handler's behavior, not just its registration.
The test only checks that
powerMonitor.onwas called with'resume'and a function; it doesn't invoke that callback to verify it actually callsupdateSupportedVersionsDatafor each server (which is the behavior described in the surrounding comment). Optional strengthening.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/servers/supportedVersions/main.main.spec.ts` around lines 2586 - 2598, Strengthen the power resume revalidation test by capturing the callback passed to powerMonitor.on in checkSupportedVersionServers, invoking it, and asserting that updateSupportedVersionsData is called for every configured server. Retain the existing registration assertion and use the test’s existing server fixtures and mocks to verify the callback behavior.src/servers/supportedVersions/main.ts (1)
809-850: 🧹 Nitpick | 🔵 TrivialResume handler fires unthrottled network refreshes for every server simultaneously.
powerMonitor.on('resume', ...)triggersupdateSupportedVersionsDatafor every server in state at once, with no staggering. For accounts with many configured servers, this could cause a burst of concurrent server/cloud requests (each with up to 3 retries and 2s delays) right after resume. Worth keeping in mind operationally, though not blocking.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/servers/supportedVersions/main.ts` around lines 809 - 850, The powerMonitor resume handler refreshes all servers concurrently, creating an unthrottled request burst. Update the resume logic in checkSupportedVersionServers to stagger or throttle calls to updateSupportedVersionsData, while preserving per-server error handling through logUpdateError and ensuring each server is eventually refreshed.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/servers/supportedVersions/main.main.spec.ts`:
- Around line 2491-2541: Add a companion success-path test for
validateFallbackAndDispatch using a well-formed cached fallback payload,
asserting it dispatches the supported-version/update actions and does not
dispatch WEBVIEW_SERVER_SUPPORTED_VERSIONS_ERROR. Ensure the test exercises the
fallback path after the network failure and verifies the promise resolves, then
fix validateFallbackAndDispatch to return immediately after successful
dispatches so the error action is not emitted.
In `@src/servers/supportedVersions/main.ts`:
- Around line 558-599: Add an immediate return after the successful verdict and
supported-versions dispatches in validateFallbackAndDispatch, before execution
can reach the error dispatch. Keep the catch path unchanged so
WEBVIEW_SERVER_SUPPORTED_VERSIONS_ERROR is dispatched only when validation
throws, and add or update coverage for the non-throwing success path.
---
Outside diff comments:
In `@src/ui/components/SupportedVersionDialog/index.tsx`:
- Around line 86-90: Update both revalidation calls in SupportedVersionDialog,
including the call containing isServerVersionSupported, to pass the server’s
supportedVersionsSource as the payloadSource argument. Ensure every invocation
uses the same source value used by updateSupportedVersionsData so cached builtin
payloads follow the strict validation path.
---
Nitpick comments:
In `@src/servers/supportedVersions/main.main.spec.ts`:
- Around line 2586-2598: Strengthen the power resume revalidation test by
capturing the callback passed to powerMonitor.on in
checkSupportedVersionServers, invoking it, and asserting that
updateSupportedVersionsData is called for every configured server. Retain the
existing registration assertion and use the test’s existing server fixtures and
mocks to verify the callback behavior.
In `@src/servers/supportedVersions/main.ts`:
- Around line 809-850: The powerMonitor resume handler refreshes all servers
concurrently, creating an unthrottled request burst. Update the resume logic in
checkSupportedVersionServers to stagger or throttle calls to
updateSupportedVersionsData, while preserving per-server error handling through
logUpdateError and ensuring each server is eventually refreshed.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: b6e59b21-3ad1-4393-b1c9-3b481c515949
📒 Files selected for processing (10)
src/i18n/en.i18n.jsonsrc/servers/reducers.tssrc/servers/reducers/__tests__/servers.spec.tssrc/servers/supportedVersions/main.main.spec.tssrc/servers/supportedVersions/main.tssrc/ui/components/ServersView/ServerPane.tsxsrc/ui/components/ServersView/UnsupportedServer.spec.tsxsrc/ui/components/ServersView/UnsupportedServer.tsxsrc/ui/components/SupportedVersionDialog/index.spec.tsxsrc/ui/components/SupportedVersionDialog/index.tsx
📜 Review details
⏰ Context from checks skipped due to timeout. (4)
- GitHub Check: CodeRabbit / Review
- GitHub Check: check (ubuntu-latest)
- GitHub Check: check (macos-latest)
- GitHub Check: check (windows-latest)
🧰 Additional context used
📓 Path-based instructions (6)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.{ts,tsx}: Use TypeScript for all new code unless explicitly told otherwise.
Use Fuselage components for all UI work; only create custom components when Fuselage does not provide what is needed.
Import UI components from@rocket.chat/fuselage.
CheckTheme.d.tsfor valid color tokens before using Fuselage theme colors.
Use optional chaining with fallbacks for platform-specific APIs, especially Linux-only process APIs likeprocess.getuid(),process.getgid(),process.geteuid(), andprocess.getegid().
Only mock platform-specific APIs when defensive coding is not possible.
Use TypeScript strict mode.
Use React functional components with hooks.
Redux actions must follow the Flux Standard Action (FSA) pattern.
Use camelCase for file names and PascalCase for components.
**/*.{ts,tsx}: Use TypeScript for new code unless explicitly told otherwise.
Use Fuselage components from@rocket.chat/fuselagefor UI work unless the design requires something Fuselage does not provide.
CheckTheme.d.tsfor valid color tokens before using Fuselage colors.
Verify library props, APIs, and tokens against official docs or local.d.tsfiles instead of assuming.
Use React functional components with hooks.
Redux actions follow FSA shape.
Use camelCase for file names and PascalCase for components.
Prefer clear names over unnecessary comments.
Prefer editing existing files over creating new abstractions unless the new abstraction removes real complexity or matches an existing pattern.
Files:
src/ui/components/ServersView/ServerPane.tsxsrc/servers/reducers.tssrc/ui/components/SupportedVersionDialog/index.tsxsrc/ui/components/ServersView/UnsupportedServer.spec.tsxsrc/servers/reducers/__tests__/servers.spec.tssrc/ui/components/SupportedVersionDialog/index.spec.tsxsrc/ui/components/ServersView/UnsupportedServer.tsxsrc/servers/supportedVersions/main.main.spec.tssrc/servers/supportedVersions/main.ts
**/*.spec.tsx
📄 CodeRabbit inference engine (CLAUDE.md)
Use
*.spec.tsxfor renderer process tests.
Files:
src/ui/components/ServersView/UnsupportedServer.spec.tsxsrc/ui/components/SupportedVersionDialog/index.spec.tsx
**/*.spec.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Renderer specs use
*.spec.ts/*.spec.tsx.
Files:
src/ui/components/ServersView/UnsupportedServer.spec.tsxsrc/servers/reducers/__tests__/servers.spec.tssrc/ui/components/SupportedVersionDialog/index.spec.tsxsrc/servers/supportedVersions/main.main.spec.ts
**/*.spec.ts
📄 CodeRabbit inference engine (CLAUDE.md)
Use
*.spec.tsfor renderer process tests.
Files:
src/servers/reducers/__tests__/servers.spec.tssrc/servers/supportedVersions/main.main.spec.ts
**/*.main.spec.ts
📄 CodeRabbit inference engine (CLAUDE.md)
Use
*.main.spec.tsfor main process tests.Main-process specs use
*.main.spec.ts.
Files:
src/servers/supportedVersions/main.main.spec.ts
src/*/*/*.spec.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Renderer specs must live in a Jest-matched nested path, such as
src/<module>/<subdir>/*.spec.ts(x); flatsrc/<module>/*.spec.tsfiles are not discovered by the currenttestMatch.
Files:
src/servers/supportedVersions/main.main.spec.ts
🧠 Learnings (1)
📚 Learning: 2026-06-26T18:14:15.295Z
Learnt from: jeanfbrito
Repo: RocketChat/Rocket.Chat.Electron PR: 3358
File: src/i18n/it-IT.i18n.json:39-42
Timestamp: 2026-06-26T18:14:15.295Z
Learning: In the i18n JSON files, the translation key `minimizeOnClose.disabledHint` is intentionally displayed when `isTrayIconEnabled` is true and the minimize-on-close toggle is disabled. The hint text should therefore instruct the user to disable the tray icon to make the setting available. During reviews, don’t “correct” this translation for seeming mismatches with the toggle state—first confirm it matches the component’s intended behavior; only update the wording if the underlying product logic/UX requirement changes.
Applied to files:
src/i18n/en.i18n.json
🔇 Additional comments (12)
src/servers/supportedVersions/main.ts (3)
5-5: LGTM!Also applies to: 85-85, 302-304, 454-464
674-675: LGTM!payloadSourcewiring and theeffectiveUniqueIdfallback (persisted uniqueID when the fresh fetch fails) are consistent with the described intent and covered by tests.Also applies to: 718-726, 741-742, 784-792
345-383: 🎯 Functional CorrectnessNo issue:
server.uniqueIDis not treated as an'UNKNOWN'sentinel. The scope check only skips falsy values, and the test case usesuniqueID: undefinedfor the “UNKNOWN” path;getUniqueId/dispatch only persist non-empty IDs.> Likely an incorrect or invalid review comment.src/servers/supportedVersions/main.main.spec.ts (1)
34-36: LGTM! These additions align with the newpayloadSource/enforcementStartDate/i18n-guard/resume-handler behavior inmain.ts.Also applies to: 478-514, 1019-1060, 2018-2073, 2075-2104, 2131-2181, 2569-2584, 2586-2598
src/servers/reducers.ts (1)
162-165: LGTM! SwitchingWEBVIEW_SERVER_UNIQUE_ID_UPDATED,WEBVIEW_SERVER_VERSION_UPDATED, andWEBVIEW_GIT_COMMIT_HASH_CHANGEDfromupserttoupdatecorrectly prevents late async identity/version updates from resurrecting a deleted server, and matches the regression tests covering unknown/deleted URLs.Also applies to: 176-188, 220-223
src/ui/components/SupportedVersionDialog/index.tsx (1)
18-38: LGTM! ThecurrentViewdependency correctly triggers revalidation on view/server switch, matching the new regression test.Also applies to: 142-144
src/ui/components/SupportedVersionDialog/index.spec.tsx (1)
1-9: LGTM!Also applies to: 172-203
src/servers/reducers/__tests__/servers.spec.ts (1)
195-205: LGTM!Also applies to: 241-251, 319-329
src/i18n/en.i18n.json (1)
492-493: LGTM!src/ui/components/ServersView/UnsupportedServer.tsx (1)
19-27: LGTM!Also applies to: 37-39, 76-78
src/ui/components/ServersView/ServerPane.tsx (1)
237-237: LGTM!src/ui/components/ServersView/UnsupportedServer.spec.tsx (1)
1-96: LGTM!
|
|
||
| // ========== FIX-1: fallback path validation must not throw unguarded ========== | ||
| describe('fallback path validation failure (fail-open guard)', () => { | ||
| it('dispatches ERROR (not a rejection) and no IS_SUPPORTED_VERSION when the fallback payload is malformed', async () => { | ||
| const mockServer = createMockServer({ version: '7.5.0' }); | ||
| selectMock.mockReturnValue(mockServer); | ||
| axiosMock.get = jest.fn().mockRejectedValue(new Error('Network error')); | ||
|
|
||
| // Cache returns a corrupt payload: `versions` is not an array, so | ||
| // isServerVersionSupported's `versions.find` throws synchronously. | ||
| const ElectronStoreMock = jest.requireMock('electron-store'); | ||
| const storeGetMock = jest.spyOn( | ||
| ElectronStoreMock.prototype, | ||
| 'get' | ||
| ) as jest.Mock; | ||
| storeGetMock.mockReturnValue({ | ||
| versions: { notAnArray: true }, | ||
| enforcementStartDate: '2023-01-01T00:00:00Z', | ||
| timestamp: new Date().toISOString(), | ||
| }); | ||
|
|
||
| const consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation(); | ||
|
|
||
| jest.useFakeTimers(); | ||
| const promise = updateSupportedVersionsData(mockServer.url); | ||
| await jest.advanceTimersByTimeAsync(4000); | ||
| // Must resolve, not reject. | ||
| await expect(promise).resolves.toBeUndefined(); | ||
| jest.useRealTimers(); | ||
|
|
||
| const errorDispatch = dispatchMock.mock.calls.find( | ||
| ([action]) => | ||
| (action as any).type === WEBVIEW_SERVER_SUPPORTED_VERSIONS_ERROR | ||
| ); | ||
| expect(errorDispatch).toBeDefined(); | ||
|
|
||
| const isSupportedDispatches = dispatchMock.mock.calls.filter( | ||
| ([action]) => | ||
| (action as any).type === WEBVIEW_SERVER_IS_SUPPORTED_VERSION | ||
| ); | ||
| expect(isSupportedDispatches.length).toBe(0); | ||
|
|
||
| expect(consoleErrorSpy).toHaveBeenCalledWith( | ||
| expect.stringContaining('Error validating fallback'), | ||
| expect.anything() | ||
| ); | ||
|
|
||
| consoleErrorSpy.mockRestore(); | ||
| storeGetMock.mockRestore(); | ||
| }); | ||
| }); |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Add a companion success-path test for validateFallbackAndDispatch.
This suite only covers the malformed-payload (throwing) branch of validateFallbackAndDispatch. As flagged in main.ts (the missing return after the success dispatches), a passing fallback validation currently also dispatches WEBVIEW_SERVER_SUPPORTED_VERSIONS_ERROR right after WEBVIEW_SERVER_IS_SUPPORTED_VERSION/WEBVIEW_SERVER_SUPPORTED_VERSIONS_UPDATED. A test asserting that a well-formed fallback payload does NOT also dispatch the error action would have caught this and prevents regression once fixed.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/servers/supportedVersions/main.main.spec.ts` around lines 2491 - 2541,
Add a companion success-path test for validateFallbackAndDispatch using a
well-formed cached fallback payload, asserting it dispatches the
supported-version/update actions and does not dispatch
WEBVIEW_SERVER_SUPPORTED_VERSIONS_ERROR. Ensure the test exercises the fallback
path after the network failure and verifies the promise resolves, then fix
validateFallbackAndDispatch to return immediately after successful dispatches so
the error action is not emitted.
| // Validates the fallback (cache/builtin) payload and dispatches the verdict. | ||
| // isServerVersionSupported can throw on a malformed cached/builtin payload | ||
| // (e.g. `versions` not an array). Left unguarded, that throw would reject | ||
| // updateSupportedVersionsData before WEBVIEW_SERVER_SUPPORTED_VERSIONS_ERROR | ||
| // is dispatched, leaving supportedVersionsFetchState stuck at 'loading' — | ||
| // which suppresses the UnsupportedServer block gate (fail-open). On failure, | ||
| // only the error state is dispatched; the prior verdict is left untouched. | ||
| const validateFallbackAndDispatch = async ( | ||
| server: Server, | ||
| serverUrl: string, | ||
| fallbackVersions: SupportedVersions, | ||
| fallbackSource: 'cloud' | 'builtin', | ||
| freshCommitHash: string | undefined, | ||
| isStale: () => boolean | ||
| ): Promise<void> => { | ||
| try { | ||
| const fallbackSupported = await isServerVersionSupported( | ||
| server, | ||
| fallbackVersions, | ||
| freshCommitHash, | ||
| fallbackSource | ||
| ); | ||
| if (isStale()) return; | ||
| dispatch({ | ||
| type: WEBVIEW_SERVER_IS_SUPPORTED_VERSION, | ||
| payload: { | ||
| url: server.url, | ||
| isSupportedVersion: fallbackSupported.supported, | ||
| }, | ||
| }); | ||
| dispatchSupportedVersionsUpdated(server.url, fallbackVersions, { | ||
| source: fallbackSource, | ||
| }); | ||
| } catch (error) { | ||
| console.error('Error validating fallback supported versions:', error); | ||
| } | ||
| if (isStale()) return; | ||
| dispatch({ | ||
| type: WEBVIEW_SERVER_SUPPORTED_VERSIONS_ERROR, | ||
| payload: { url: serverUrl }, | ||
| }); | ||
| }; |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🔴 Critical | ⚡ Quick win
Critical: success path also dispatches the ERROR action, corrupting supportedVersionsFetchState.
In validateFallbackAndDispatch, the try block has no return after the success dispatches (lines 581-590). Execution falls through past the catch block to lines 594-598, which unconditionally dispatches WEBVIEW_SERVER_SUPPORTED_VERSIONS_ERROR — even on the success path. Per the reducer, this overwrites supportedVersionsFetchState from 'success' (just set by dispatchSupportedVersionsUpdated) to 'error' immediately after every successful fallback validation. This contradicts the function's own comment ("On failure, only the error state is dispatched; the prior verdict is left untouched") and defeats the fail-open guard for the normal (non-throwing) case.
The existing regression test only exercises the malformed-payload (throwing) branch, so it doesn't catch this.
🐛 Proposed fix: add missing `return` on the success path
try {
const fallbackSupported = await isServerVersionSupported(
server,
fallbackVersions,
freshCommitHash,
fallbackSource
);
if (isStale()) return;
dispatch({
type: WEBVIEW_SERVER_IS_SUPPORTED_VERSION,
payload: {
url: server.url,
isSupportedVersion: fallbackSupported.supported,
},
});
dispatchSupportedVersionsUpdated(server.url, fallbackVersions, {
source: fallbackSource,
});
+ return;
} catch (error) {
console.error('Error validating fallback supported versions:', error);
}
if (isStale()) return;
dispatch({
type: WEBVIEW_SERVER_SUPPORTED_VERSIONS_ERROR,
payload: { url: serverUrl },
});
};📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| // Validates the fallback (cache/builtin) payload and dispatches the verdict. | |
| // isServerVersionSupported can throw on a malformed cached/builtin payload | |
| // (e.g. `versions` not an array). Left unguarded, that throw would reject | |
| // updateSupportedVersionsData before WEBVIEW_SERVER_SUPPORTED_VERSIONS_ERROR | |
| // is dispatched, leaving supportedVersionsFetchState stuck at 'loading' — | |
| // which suppresses the UnsupportedServer block gate (fail-open). On failure, | |
| // only the error state is dispatched; the prior verdict is left untouched. | |
| const validateFallbackAndDispatch = async ( | |
| server: Server, | |
| serverUrl: string, | |
| fallbackVersions: SupportedVersions, | |
| fallbackSource: 'cloud' | 'builtin', | |
| freshCommitHash: string | undefined, | |
| isStale: () => boolean | |
| ): Promise<void> => { | |
| try { | |
| const fallbackSupported = await isServerVersionSupported( | |
| server, | |
| fallbackVersions, | |
| freshCommitHash, | |
| fallbackSource | |
| ); | |
| if (isStale()) return; | |
| dispatch({ | |
| type: WEBVIEW_SERVER_IS_SUPPORTED_VERSION, | |
| payload: { | |
| url: server.url, | |
| isSupportedVersion: fallbackSupported.supported, | |
| }, | |
| }); | |
| dispatchSupportedVersionsUpdated(server.url, fallbackVersions, { | |
| source: fallbackSource, | |
| }); | |
| } catch (error) { | |
| console.error('Error validating fallback supported versions:', error); | |
| } | |
| if (isStale()) return; | |
| dispatch({ | |
| type: WEBVIEW_SERVER_SUPPORTED_VERSIONS_ERROR, | |
| payload: { url: serverUrl }, | |
| }); | |
| }; | |
| // Validates the fallback (cache/builtin) payload and dispatches the verdict. | |
| // isServerVersionSupported can throw on a malformed cached/builtin payload | |
| // (e.g. `versions` not an array). Left unguarded, that throw would reject | |
| // updateSupportedVersionsData before WEBVIEW_SERVER_SUPPORTED_VERSIONS_ERROR | |
| // is dispatched, leaving supportedVersionsFetchState stuck at 'loading' — | |
| // which suppresses the UnsupportedServer block gate (fail-open). On failure, | |
| // only the error state is dispatched; the prior verdict is left untouched. | |
| const validateFallbackAndDispatch = async ( | |
| server: Server, | |
| serverUrl: string, | |
| fallbackVersions: SupportedVersions, | |
| fallbackSource: 'cloud' | 'builtin', | |
| freshCommitHash: string | undefined, | |
| isStale: () => boolean | |
| ): Promise<void> => { | |
| try { | |
| const fallbackSupported = await isServerVersionSupported( | |
| server, | |
| fallbackVersions, | |
| freshCommitHash, | |
| fallbackSource | |
| ); | |
| if (isStale()) return; | |
| dispatch({ | |
| type: WEBVIEW_SERVER_IS_SUPPORTED_VERSION, | |
| payload: { | |
| url: server.url, | |
| isSupportedVersion: fallbackSupported.supported, | |
| }, | |
| }); | |
| dispatchSupportedVersionsUpdated(server.url, fallbackVersions, { | |
| source: fallbackSource, | |
| }); | |
| return; | |
| } catch (error) { | |
| console.error('Error validating fallback supported versions:', error); | |
| } | |
| if (isStale()) return; | |
| dispatch({ | |
| type: WEBVIEW_SERVER_SUPPORTED_VERSIONS_ERROR, | |
| payload: { url: serverUrl }, | |
| }); | |
| }; |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/servers/supportedVersions/main.ts` around lines 558 - 599, Add an
immediate return after the successful verdict and supported-versions dispatches
in validateFallbackAndDispatch, before execution can reach the error dispatch.
Keep the catch path unchanged so WEBVIEW_SERVER_SUPPORTED_VERSIONS_ERROR is
dispatched only when validation throws, and add or update coverage for the
non-throwing success path.
Jira: CORE-2409
Stacked on #3404 — retarget to
masterafter it merges.What
Follow-up hardening pass over the supported-versions subsystem after the exception-scope investigation in #3404. Two independent audits (main-process flow and renderer surfaces) produced the findings below; every fix ships with a regression test.
Fixes
Validation robustness (main process)
updateSupportedVersionsDatabefore the error state was dispatched, leavingsupportedVersionsFetchStatestuck at'loading'— which suppresses the UnsupportedServer block gate. The error state is now always dispatched and the prior verdict is preserved.refresh-supported-versionsIPC handler).powerMonitor'resume'— the window'online'event does not fire when waking with the same network still connected.Exception scoping
settings.publicrestricted by API access controls) is never treated as a scope mismatch.exceptions.domaincomparison was already made case-insensitive in fix: honor uniqueId-scoped support exceptions on server-signed path #3404.State integrity
WEBVIEW_SERVER_UNIQUE_ID_UPDATED,WEBVIEW_SERVER_VERSION_UPDATED, andWEBVIEW_GIT_COMMIT_HASH_CHANGEDreducer cases switched fromupserttoupdate: a late identity dispatch for a server deleted while a validation was in flight can no longer resurrect a ghost server entry.Renderer
SupportedVersionDialogeffect dependencies used the importedcurrentViewreducer function (never changes) instead of the state value, so the dialog never re-checked when switching server views. Now selects the real state.getExpirationMessageTranslatedagainst payloads whose i18n dictionary lacks both the user language anden; the unguarded lookup crashed the async check and silently suppressed the expiring-workspace warning dialog.unsupportedServer.checkAgainen key; other locales fall back).Enforcement certainty
enforcementStartDateno longer blocks the workspace: an Invalid Date previously failed the future-date comparison and fell through to the unsupported verdict on incomplete payload data. Blocking now requires a valid, past enforcement date.Cosmetic
logRequestErrorprinted a literal${description}(single-quoted string).Out of scope, tracked for follow-up
enforcementStartDate⇒ supported (global grace masks a lapsed exception) — needs product confirmation.uniqueId/commit/full patch version in/api/info, which real unauthenticated servers do not send.Tests
tsc --noEmitandyarn lintclean.Summary by CodeRabbit
Recreation of #3405, which was auto-closed when its stacked base branch was deleted during the merge of #3404. Same branch, same content.