okta / okta-sdk-golang

A Golang SDK for interacting with the Okta management API, enabling server-side code to manage Okta users, groups, applications, and more.
https://github.com/okta/okta-sdk-golang
Other
173 stars 143 forks source link

Skip caching failed dumps of http responses #380

Open andrejgou opened 1 year ago

andrejgou commented 1 year ago

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: https://github.com/okta/okta-sdk-golang/blob/758b8c38315d262ab5aedb4694655d48ebb68384/okta/requestExecutor.go#L668 called from this line: https://github.com/okta/okta-sdk-golang/blob/1d378b9b66749810bad94d50019e7693d2aaf039/okta/requestExecutor.go#L470 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: https://github.com/okta/okta-sdk-golang/blob/758b8c38315d262ab5aedb4694655d48ebb68384/okta/cache/goCache.go#L59

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

github-actions[bot] commented 1 year ago

This PR has been marked stale because there has been no activity within the last 28 days. To keep this PR active, remove the stale label.

github-actions[bot] commented 1 year ago

This PR has been marked stale because there has been no activity within the last 28 days. To keep this PR active, remove the stale label.