Repository navigation
Fix stale supported-versions cache outranking fresh builtin fallback - #3388
Conversation
…fallback Fixes #3385. When server and cloud fetches both fail, the fallback chain trusted a persisted disk cache unconditionally over the app's bundled builtin supported-versions list. A cache entry written before an app update - before the server's version was added to the supported list - would outrank a freshly-shipped builtin list that already supports it, producing a permanent false "unsupported version" block until the user manually wiped the app's userData cache. Compare the `timestamp` field on cached vs builtin payloads and use whichever is more recent, instead of a fixed cache-first priority.
WalkthroughThe fallback logic in the supported versions module was reworked to compare timestamps between cached and builtin supported-version data, selecting the fresher source instead of always preferring cache. A regression test validates that builtin data is used over a stale cache. ChangesFreshness-based supported versions fallback
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant App
participant FallbackLogic as SupportedVersionsFallback
participant Cache
participant Builtin as BuiltinData
App->>FallbackLogic: server and cloud unreachable
FallbackLogic->>Cache: load cached supported versions
FallbackLogic->>Builtin: load builtin supported versions
FallbackLogic->>FallbackLogic: parseTimestamp(cache), parseTimestamp(builtin)
FallbackLogic->>FallbackLogic: compare timestamps, choose fresher source
alt builtin is fresher
FallbackLogic->>App: dispatch verdict with source='builtin'
else cache is fresher
FallbackLogic->>Cache: update cache
FallbackLogic->>App: dispatch verdict with source='cloud'
end
Possibly related PRs
Suggested labels: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration. 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
🤖 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.ts`:
- Around line 669-671: The fallback provenance is being misreported because the
cache path in supportedVersions/main.ts still maps reused cached entries to
supportedVersionsSource = 'cloud'. Update the fallback handling around
fallbackSource so cached results are tagged distinctly (for example, with a new
cache source) or carry through the original source alongside the cached payload.
Make the change in the code that builds and dispatches the supported versions
source so the UI can distinguish cache reuse from a true cloud fetch.
🪄 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: 0fce8ce4-6f6f-4351-8d5b-f09cd2b69a44
📒 Files selected for processing (2)
src/servers/supportedVersions/main.main.spec.tssrc/servers/supportedVersions/main.ts
📜 Review details
⏰ Context from checks skipped due to timeout. (3)
- GitHub Check: check (macos-latest)
- GitHub Check: check (ubuntu-latest)
- GitHub Check: check (windows-latest)
🧰 Additional context used
📓 Path-based instructions (6)
**/*.ts
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.ts: Use TypeScript for all new code unless explicitly told otherwise
Use optional chaining with fallbacks for platform-specific APIs instead of mocking when possible. Example:const uid = process.getuid?.() ?? 1000;
Files:
src/servers/supportedVersions/main.main.spec.tssrc/servers/supportedVersions/main.ts
**/*.{tsx,ts}
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.{tsx,ts}: MANDATORY: Use Fuselage components for all UI work. Only create custom components when Fuselage doesn't provide what's needed
Import UI components from@rocket.chat/fuselageand checkTheme.d.tsfor valid color tokens
Use React functional components with hooks
Use PascalCase for component file names
Files:
src/servers/supportedVersions/main.main.spec.tssrc/servers/supportedVersions/main.ts
**/*.spec.ts
📄 CodeRabbit inference engine (CLAUDE.md)
Use
*.spec.tsfile naming for Renderer process tests
Files:
src/servers/supportedVersions/main.main.spec.ts
**/*.main.spec.ts
📄 CodeRabbit inference engine (CLAUDE.md)
Use
*.main.spec.tsfile naming for Main process tests
Files:
src/servers/supportedVersions/main.main.spec.ts
**/*.{spec.ts,main.spec.ts}
📄 CodeRabbit inference engine (CLAUDE.md)
Only mock platform-specific APIs when defensive coding isn't possible. Linux-only APIs requiring mocks:
process.getuid(),process.getgid(),process.geteuid(),process.getegid()
Files:
src/servers/supportedVersions/main.main.spec.ts
**/*.{ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.{ts,tsx}: Redux actions must follow FSA (Flux Standard Action) pattern
Avoid unnecessary comments — write self-documenting code through clear naming
Always verify libraries by checking official docs and.d.tsfiles innode_modules/. Never assume props, tokens, or APIs work without verification
Avoid subjective descriptors ('smart', 'excellent', 'dumb') in documentation and comments
Use measurable descriptions in code documentation: 'reduced memory usage', 'improved by X%' instead of subjective claims
NEVER invent metrics — don't include estimated time spent or speculated user counts. Only include numbers from actual logs, error messages, or documented sources
Files:
src/servers/supportedVersions/main.main.spec.tssrc/servers/supportedVersions/main.ts
🔇 Additional comments (2)
src/servers/supportedVersions/main.ts (1)
93-98: LGTM!src/servers/supportedVersions/main.main.spec.ts (1)
1342-1432: LGTM!
| const fallbackSource: 'cloud' | 'builtin' = useBuiltinOverCache | ||
| ? 'builtin' | ||
| : 'cloud'; |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Inspect the valid supportedVersionsSource values and how the label is consumed.
rg -nP "supportedVersionsSource\??\s*:" src/servers/common.ts src/servers/supportedVersions/types.ts 2>/dev/null
fd -e ts | xargs rg -nP "supportedVersionsSource" -C2Repository: RocketChat/Rocket.Chat.Electron
Length of output: 2412
🏁 Script executed:
#!/bin/bash
sed -n '640,700p' src/servers/supportedVersions/main.ts
rg -n "useBuiltinOverCache|fallbackSource|supportedVersionsSource|supportedVersions" src/servers/supportedVersions src/servers -C 2Repository: RocketChat/Rocket.Chat.Electron
Length of output: 50387
🏁 Script executed:
#!/bin/bash
rg -n "supportedVersionsSource" src -C 3
rg -n "useBuiltinOverCache|fallbackSource|cachedVersions|cache.*builtin|builtinOverCache" src/servers/supportedVersions/main.main.spec.ts src/servers/supportedVersions/main.ts -C 3Repository: RocketChat/Rocket.Chat.Electron
Length of output: 22584
🏁 Script executed:
#!/bin/bash
sed -n '560,640p' src/servers/supportedVersions/main.ts
sed -n '1338,1490p' src/servers/supportedVersions/main.main.spec.ts
rg -n "saveToCache\\(|dispatchSupportedVersionsUpdated\\(" src/servers/supportedVersions/main.ts src/servers/supportedVersions/main.main.spec.ts -C 2Repository: RocketChat/Rocket.Chat.Electron
Length of output: 12117
Cache fallback should not be labeled as cloud. The fallback path reuses persisted cache entries from any prior source, but supportedVersionsSource is still dispatched as 'cloud', so the UI shows the wrong provenance. Add a distinct cache source or persist the original source with the cached payload.
🤖 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 669 - 671, The fallback
provenance is being misreported because the cache path in
supportedVersions/main.ts still maps reused cached entries to
supportedVersionsSource = 'cloud'. Update the fallback handling around
fallbackSource so cached results are tagged distinctly (for example, with a new
cache source) or carry through the original source alongside the cached payload.
Make the change in the code that builds and dispatches the supported versions
source so the UI can distinguish cache reuse from a true cloud fetch.
|
@jeanfbrito Thank you for the quick fix :-) |
…nfo contract; try both fallback sources The desktop's ServerInfo type declared fields the server never returns to unauthenticated callers (verified against the server source, apps/meteor/server/api/lib/getServerInfo.ts): - Remove the fictional uniqueId field. No server version includes it in /api/info; the workspace uniqueID comes from settings.public and is resolved on demand by withExceptionScopeUniqueId. Remove the dead serverInfoResult.uniqueId fallback in updateSupportedVersionsData. - Mark build, marketplaceApiVersion, and commit optional and document that they only appear for authenticated view-statistics callers; the desktop always calls /api/info unauthenticated. The sha-exception path uses the persisted server.gitCommitHash pushed by the injected script instead. - Rebuild the default test fixture to mirror the real unauthenticated wire shape (trimmed major.minor version, no uniqueId/commit/info) so the suite can no longer validate assumptions against fields real servers do not send — the gap that let the exception-scope defect pass CI. Switch beforeEach to jest.resetAllMocks(), fixing latent cross-test mock leakage the honest fixtures surfaced. Also rework the offline fallback to try BOTH remaining sources instead of picking one by timestamp: the bundled builtin payload never carries tenant exceptions, so preferring a fresher builtin over a cache that holds the tenant's exception blocked a workspace that should stay usable. Candidates are checked in freshness order and the first source that supports the server wins; blocking requires every available source to fail. This keeps the stale-cache rescue from #3388 while never losing a cached exception to it.
…nfo contract; try both fallback sources The desktop's ServerInfo type declared fields the server never returns to unauthenticated callers (verified against the server source, apps/meteor/server/api/lib/getServerInfo.ts): - Remove the fictional uniqueId field. No server version includes it in /api/info; the workspace uniqueID comes from settings.public and is resolved on demand by withExceptionScopeUniqueId. Remove the dead serverInfoResult.uniqueId fallback in updateSupportedVersionsData. - Mark build, marketplaceApiVersion, and commit optional and document that they only appear for authenticated view-statistics callers; the desktop always calls /api/info unauthenticated. The sha-exception path uses the persisted server.gitCommitHash pushed by the injected script instead. - Rebuild the default test fixture to mirror the real unauthenticated wire shape (trimmed major.minor version, no uniqueId/commit/info) so the suite can no longer validate assumptions against fields real servers do not send — the gap that let the exception-scope defect pass CI. Switch beforeEach to jest.resetAllMocks(), fixing latent cross-test mock leakage the honest fixtures surfaced. Also rework the offline fallback to try BOTH remaining sources instead of picking one by timestamp: the bundled builtin payload never carries tenant exceptions, so preferring a fresher builtin over a cache that holds the tenant's exception blocked a workspace that should stay usable. Candidates are checked in freshness order and the first source that supports the server wins; blocking requires every available source to fail. This keeps the stale-cache rescue from #3388 while never losing a cached exception to it.
…tion-aware fallback (#3406) * fix: align supported-versions types and fixtures with the real /api/info contract; try both fallback sources The desktop's ServerInfo type declared fields the server never returns to unauthenticated callers (verified against the server source, apps/meteor/server/api/lib/getServerInfo.ts): - Remove the fictional uniqueId field. No server version includes it in /api/info; the workspace uniqueID comes from settings.public and is resolved on demand by withExceptionScopeUniqueId. Remove the dead serverInfoResult.uniqueId fallback in updateSupportedVersionsData. - Mark build, marketplaceApiVersion, and commit optional and document that they only appear for authenticated view-statistics callers; the desktop always calls /api/info unauthenticated. The sha-exception path uses the persisted server.gitCommitHash pushed by the injected script instead. - Rebuild the default test fixture to mirror the real unauthenticated wire shape (trimmed major.minor version, no uniqueId/commit/info) so the suite can no longer validate assumptions against fields real servers do not send — the gap that let the exception-scope defect pass CI. Switch beforeEach to jest.resetAllMocks(), fixing latent cross-test mock leakage the honest fixtures surfaced. Also rework the offline fallback to try BOTH remaining sources instead of picking one by timestamp: the bundled builtin payload never carries tenant exceptions, so preferring a fresher builtin over a cache that holds the tenant's exception blocked a workspace that should stay usable. Candidates are checked in freshness order and the first source that supports the server wins; blocking requires every available source to fail. This keeps the stale-cache rescue from #3388 while never losing a cached exception to it. * test: add live /api/info wire-contract spec Asserts the unauthenticated /api/info response shape against a real server (open.rocket.chat): trimmed major.minor version, no uniqueId, no commit/info blocks, string minimumClientVersions, JWT-shaped supportedVersions.signed. Skips only on genuine network failure or SKIP_CONTRACT_TESTS=1, so contract drift between the desktop and the server cannot hide behind mocks that agree with themselves.
* fix: honor uniqueId-scoped support exceptions on server-signed path The exception scope check introduced in #3323 requires exceptions.uniqueId to equal server.uniqueID, but the server-signed validation path returns before getUniqueId() ever runs and /api/info does not include a uniqueId field, so the local uniqueID is missing on that path and uniqueId-scoped exceptions were always disqualified. Resolve the workspace uniqueID from the server before validating when the payload carries a uniqueId-scoped exceptions block, persist it via WEBVIEW_SERVER_UNIQUE_ID_UPDATED so subsequent runs (including offline cache validation) keep working, and keep rejecting when the fetched value does not match. Also compare exceptions.domain case-insensitively (DNS names are case-insensitive per RFC 4343). * fix: harden supported-versions validation and recovery paths 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. * fix: honor tenant-scoped exceptions from self-scoped payload sources 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). * fix: do not block when enforcementStartDate is missing or malformed 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. * fix: align supported-versions types and fixtures with the real /api/info contract; try both fallback sources The desktop's ServerInfo type declared fields the server never returns to unauthenticated callers (verified against the server source, apps/meteor/server/api/lib/getServerInfo.ts): - Remove the fictional uniqueId field. No server version includes it in /api/info; the workspace uniqueID comes from settings.public and is resolved on demand by withExceptionScopeUniqueId. Remove the dead serverInfoResult.uniqueId fallback in updateSupportedVersionsData. - Mark build, marketplaceApiVersion, and commit optional and document that they only appear for authenticated view-statistics callers; the desktop always calls /api/info unauthenticated. The sha-exception path uses the persisted server.gitCommitHash pushed by the injected script instead. - Rebuild the default test fixture to mirror the real unauthenticated wire shape (trimmed major.minor version, no uniqueId/commit/info) so the suite can no longer validate assumptions against fields real servers do not send — the gap that let the exception-scope defect pass CI. Switch beforeEach to jest.resetAllMocks(), fixing latent cross-test mock leakage the honest fixtures surfaced. Also rework the offline fallback to try BOTH remaining sources instead of picking one by timestamp: the bundled builtin payload never carries tenant exceptions, so preferring a fresher builtin over a cache that holds the tenant's exception blocked a workspace that should stay usable. Candidates are checked in freshness order and the first source that supports the server wins; blocking requires every available source to fail. This keeps the stale-cache rescue from #3388 while never losing a cached exception to it. * test: add live /api/info wire-contract spec Asserts the unauthenticated /api/info response shape against a real server (open.rocket.chat): trimmed major.minor version, no uniqueId, no commit/info blocks, string minimumClientVersions, JWT-shaped supportedVersions.signed. Skips only on genuine network failure or SKIP_CONTRACT_TESTS=1, so contract drift between the desktop and the server cannot hide behind mocks that agree with themselves. * fix(CORE-2400): remove startup screen capture enumeration that opens Wayland picker (#3308) (#3400) * chore: bump version to 4.15.3
Summary
Fixes #3385. Server on a fully supported version (8.5.1 LTS) got permanently blocked with "unsupported version" on 4.15.0. Workaround reported by user: deleting
AppData\Roaming\Rocket.Chat(the app's userData/cache dir) fixed it.Root cause: in
updateSupportedVersionsData(src/servers/supportedVersions/main.ts), when both the server-embedded and cloud supported-versions fetches fail, the fallback chain picked the persisted disk cache unconditionally over the app's own bundled builtin list. A cache entry written by an older app version — before the server's version was added to the supported list — permanently outranks a freshly-shipped builtin list that already supports it, with no TTL or freshness check. TheSupportedVersions.timestampfield exists specifically for this purpose but was never read.What changed
timestampon the cached payload vs the builtin payload and use whichever is more recent, instead of a fixed cache-first priority.parseTimestamphelper: missing/invalid timestamps sort as oldest, so a corrupt timestamp can't spuriously win the comparison.Not touched: the exception/version-matching logic from #3323 (still correct), and #3371 (role-targeted messages, unrelated to the block verdict).
Test plan
main.main.spec.tssuite passes (77/77).eslintclean on both changed files.tsc --noEmitshows no new errors introduced by this change (14 pre-existing errors in the worktree are unrelated React 18/19 type mismatches, confirmed present withgit stash).Summary by CodeRabbit