Skip to content

fix: consult cache on network-level errors in PostQuery (KSM-921) - #66

Merged
stas-schaller merged 1 commit into
release/sdk/golang/core/v1.7.0from
KSM-921-cache-network-fallback
Apr 30, 2026
Merged

fix: consult cache on network-level errors in PostQuery (KSM-921)#66
stas-schaller merged 1 commit into
release/sdk/golang/core/v1.7.0from
KSM-921-cache-network-fallback

Conversation

@stas-schaller

Copy link
Copy Markdown
Contributor

Summary

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 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.rs is the closest parallel — it explicitly handles Ok(response) and Err(network_error) as separate match arms, falling back on the latter.

Related Issues

Closes KSM-921
Part of v1.7.0 release (PR #51)

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
stas-schaller merged commit 2094268 into release/sdk/golang/core/v1.7.0 Apr 30, 2026
2 checks passed
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.

1 participant