Repository navigation
fix(api): a session refused over its Stream app's keys is answered with the refusal, not a 500 - #2354
Merged
Merged
Conversation
…th the refusal A fork, a resume and an app-mode create on a Stream app whose keys Stream refuses answered a 500 saying only that something went wrong. refusedRequest now answers the deployment's refusal as not_configured on every path, and an app's own refused keys are a refusal of their own, answered as invalid_request without the deployment's variables.
| func (s *Server) logUnkept(customerID string, err error) { | ||
| if found, ok := errors.AsType[*session.UnkeptError](err); ok { | ||
| s.logger.Warn("a session that is not incognito has no Stream app to be kept in", | ||
| "customer", customerID, "error", err, "cause", found.Cause) |
dangusev
approved these changes
Nov 24, 2026
thesyncim
commented
Nov 24, 2026
Member
Author
There was a problem hiding this comment.
Looks good — the app-mode/deployment-mode split and moving unkeptAnswer into refusedRequest are clean.
Just need to clear the CodeQL alert on session_create.go:89 (false positive since UnkeptError.Error() is a static string, but it's failing CI).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
#2295 refused a session on a deployment whose Stream app keys Stream rejects with its own sentence. A fork reached that refusal through
refusedRequest, and so did an app-mode create whose own app rejects its keys. #2295 relied onrefusedRequestanswering any error as a 400 with the error's text. #2248, already on #2295's branch, had changed that: an errorrefusedRequestdoes not recognise is now a 500 "something went wrong". These paths never answered correctly on main. Their tests inSelfHostedSessionsSuiteandAppModeSessionsSuitecould not run until #2341 fixed the package's compile, sointegration (api)fails on every PR.Fix
refusedRequest(money.go) answersErrNoStreamKeysandErrStreamKeysRejectedthroughunkeptAnswer, asnot_configured. Create, fork, resume, voice and the socket now give this refusal the same code and status.unkeptIn(session/stream_keys.go) maps Stream's 401 for an app's own keys to a newErrAppStreamKeysRejected. That error is a caller mistake, answered asinvalid_requestin our own words. It names no deployment variable and none of Stream's text. Before, the rawStreamErrorwent through as a 500.logUnkept). A resume answers correctly but does not log the cause.Tests
TestAForkOnKeysStreamRefusesNamesTheKeysWithNothingOfStreamscaught a fork answered as a 500. It now also assertsnot_configured. It failed on main with 500 "something went wrong".TestAPersistedTextSessionIntoAnAppRefusingItsKeysIsNotTheDeploymentsToFixcaught an app's refused keys answered as a 500. It failed on main with a 500. It now also assertsinvalid_requestand our sentence, and that Stream's "api_key not valid" stays out of the body. Without that last check, putting back the old catch-allinvalidRequest(err.Error())would pass.TestInAppModeTheAppIsTheCustomers(unit) now expectsErrAppStreamKeysRejectedwithoutSTREAM_API_KEY, where it expected nil.-count=3. Five mutants were each killed: no unkept case inrefusedRequest, the app-mode branch returning nil, the app refusal answerednot_configured, the old catch-all, and the app refusal dropped fromcallerMistakes.