Skip caching failed dumps of http responses #380
Draft
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.
Errors when dumping the response are ignored so an empty value is cached, which causes deserialization of the response to fail with an error, which is also ignored, which causes a nil pointer panic.
Summary
Okta HTTP requests were occasionally failing with nil pointer panics. The stack trace showed the panic originating from this line:
okta-sdk-golang/okta/requestExecutor.go
Line 668 in 758b8c3
called from this line:
okta-sdk-golang/okta/requestExecutor.go
Line 470 in 1d378b9
The only way the HTTP response can be nil is if deserialization fails, which can only fail if the cached value is invalid, which can only happen if serialization of the HTTP response fails when setting the value in the cache:
okta-sdk-golang/okta/cache/goCache.go
Line 59 in 758b8c3
The easiest fix I could think of was to just skip setting the cache for values that failed serialization. The only potential impact is additional cache misses, but only for invalid values that aren't usable anyway.
Fixes N/A
Type of PR
Test Information
Go Version:
Os Version:
OpenAPI Spec Version:
Signoff
make fmt
on my code