Skip to content

fix: validate cached instanceApiVersion before use @W-23157155@#1307

Open
WillieRuemmele wants to merge 2 commits into
mainfrom
wr/fixCachedApiVersionValidation
Open

fix: validate cached instanceApiVersion before use @W-23157155@#1307
WillieRuemmele wants to merge 2 commits into
mainfrom
wr/fixCachedApiVersionValidation

Conversation

@WillieRuemmele

Copy link
Copy Markdown
Member

Summary

  • Validate on read: getCachedApiVersion() now validates the cached instanceApiVersion via validateApiVersion() before returning it. Invalid values (e.g. "latest") are logged at warn level and ignored, forcing a fresh fetch from services/data.
  • Validate on write: AuthInfo.update() strips invalid instanceApiVersion values before persisting, preventing the poisoned-cache scenario at the source.
  • Improved fallback logging: useLatestApiVersion() now logs the actual version being fallen back to (e.g. v50.0) so the degradation is visible in debug output.

Work Item

@W-23157155@: getCachedApiVersion() returns cached instanceApiVersion without re-validating, silently degrading to jsforce default (v50)

Proof of Work

  • Tests: 1158 passing (unit), 57 passing (NUT)
  • Lint: clean (0 errors, pre-existing warnings only)
  • Type check: clean
  • Build: clean

Test plan

  • Set instanceApiVersion: "latest" in ~/.sfdx/<username>.json and verify connection.getApiVersion() returns the org's real max version (not 50.0)
  • Verify that AuthInfo.save({ instanceApiVersion: 'latest' }) strips the invalid value and logs a warning
  • Verify valid cached versions (e.g. "61.0") are still used from cache without a network call
  • Verify expired cache (>24h) still triggers a re-fetch as before

@WillieRuemmele WillieRuemmele requested a review from a team as a code owner June 26, 2026 17:01
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.

2 participants