fix: consult cache on network-level errors in PostQuery (KSM-921) - #66
Merged
stas-schaller merged 1 commit intoApr 30, 2026
Merged
Conversation
When PostFunction returns a transport-level error (DNS failure, connection refused, TLS error, timeout), PostQuery now checks ICache.GetCachedValue before returning the error. If the cache has a valid prior payload the SDK serves those records and logs a warning; if the cache is empty the original network error surfaces unchanged. Previously the cache-check at core.go:822 was unreachable on the err != nil path — the function returned immediately at line 819. This made the offline-fallback useless for the most common real-world outage mode (Keeper API truly unreachable from the consumer's network). Behavior is now consistent with Python, JavaScript, .NET, Java, and Rust SDK cache implementations, all of which fall back on transport exceptions. Closes KSM-921
stas-schaller
merged commit Apr 30, 2026
2094268
into
release/sdk/golang/core/v1.7.0
2 checks passed
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When
PostFunctionreturns a transport-level error (DNS failure, connection refused, TLS error, timeout),PostQuerynow checksICache.GetCachedValuebefore returning the error. If the cache has a valid prior payload the SDK serves those records and logs a warning; if the cache is empty the original network error surfaces unchanged.Previously the cache-check at
core.go:822was unreachable on theerr != nilpath — the function returned at line 819 before reaching it. This meant the offline-fallback provided zero resilience for the most common real-world outage mode (Keeper API truly unreachable from the consumer's network), even though it correctly served cached records when the server was up but returning 4xx/5xx.Behavior is now consistent with the Python, JavaScript, .NET, Java, and Rust SDK implementations, all of which fall back to cache on transport-level exceptions. Rust's
caching.rsis the closest parallel — it explicitly handlesOk(response)andErr(network_error)as separate match arms, falling back on the latter.Related Issues
Closes KSM-921
Part of v1.7.0 release (PR #51)