You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using secretcache with an incomplete config (not setting all fields) it results in a panic on secrets.GetSecretString.
I.e., the following code panicks:
config:= secretcache.CacheConfig{
// Uncomment the defaults below to make the example work again// MaxCacheSize: secretcache.DefaultMaxCacheSize,// VersionStage: secretcache.DefaultVersionStage,CacheItemTTL: 30*1000*1000*1000,
}
secrets, err:=secretcache.New(
func(c*secretcache.Cache) { c.CacheConfig=config },
)
iferr!=nil {
panic(fmt.Errorf("error creating secret cache: %w", err))
}
secrets.GetSecretString("foo")
Expected to receive an error from either secretcache.New for an incomplete configuration or cache.GetSecretString for an invalid secret ID. It should not panic.
Current Behavior
The example panics due to a nil pointer dereference.
This is the output:
Just run the minimal example here (go run main.go) or copy above code to a file and run it.
Possible Solution
If there are assumptions about the config (e.g.: MaxCacheSize > 0), they may be checked on secretcache.New. A descriptive error could be returned, if something is not met.
Version used
v1.1.0
Environment details (Version of Go (go version)? OS name and version, etc.)
go version go1.19.1 linux/amd64
The text was updated successfully, but these errors were encountered:
Describe the bug
When using
secretcache
with an incomplete config (not setting all fields) it results in a panic onsecrets.GetSecretString
.I.e., the following code panicks:
Find a minimal working example also here: https://github.com/merschformann/aws-secrets-manager-panic
Expected Behavior
Expected to receive an error from either
secretcache.New
for an incomplete configuration orcache.GetSecretString
for an invalid secret ID. It should not panic.Current Behavior
The example panics due to a nil pointer dereference.
This is the output:
Reproduction Steps
Just run the minimal example here (
go run main.go
) or copy above code to a file and run it.Possible Solution
If there are assumptions about the config (e.g.:
MaxCacheSize > 0
), they may be checked onsecretcache.New
. A descriptive error could be returned, if something is not met.Version used
v1.1.0
Environment details (Version of Go (
go version
)? OS name and version, etc.)go version go1.19.1 linux/amd64
The text was updated successfully, but these errors were encountered: