Skip to content

registry: don't panic when store.New returns a nil session#291

Open
c-tonneslan wants to merge 1 commit into
gorilla:mainfrom
c-tonneslan:fix-registry-get-nil-panic
Open

registry: don't panic when store.New returns a nil session#291
c-tonneslan wants to merge 1 commit into
gorilla:mainfrom
c-tonneslan:fix-registry-get-nil-panic

Conversation

@c-tonneslan

Copy link
Copy Markdown

Fixes #288.

Registry.Get called store.New and then immediately dereferenced the returned session via session.name = name and session.store = store. Stores can legitimately return (nil, err) from New (e.g. backend unreachable, decode failure, allocation error). When they do, the request crashes with a nil pointer dereference instead of propagating the error.

Now: if the store returns a nil session, the error is recorded in the registry cache and returned to the caller. Existing happy-path tests still pass, plus a regression test covering a store that returns (nil, err).

Stores can legitimately return (nil, err) from New (e.g. backend
unavailable). Registry.Get then dereferenced the nil session for
session.name and session.store and crashed the request. Return the
store's error instead.

Signed-off-by: Charlie Tonneslan <cst0520@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Panic if store.New returns an error

1 participant