fix(auth): stop putting the raw JWT in UserDoesntExist - #1602
Open
grdsdev wants to merge 1 commit into
Open
Conversation
UserDoesntExist stored the access token and never called Exception.__init__ with a message. BaseException.__new__ still set args = (access_token,), so str(e) and every traceback line printed the raw user JWT into logs and error trackers. The class now takes no arguments and carries a fixed, non-secret message. It also derives from CustomAuthError instead of Exception, so `except AuthError` catches it like every other auth error. BREAKING CHANGE: UserDoesntExist() takes no arguments and no longer has an .access_token attribute.
Contributor
|
The following capabilities are marked
The following capabilities are marked
These may have been renamed, removed, or never registered. Please update the capability matrix. |
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.
Closes SDK-1678.
The problem
UserDoesntExiststored the access token and never calledException.__init__with a message:BaseException.__new__still setsargs = (access_token,). Sostr(e)and every traceback line printed the raw user JWT. It reached application logs, error trackers, and any traceback shown to an end user.It is raised from
set_sessionand_get_session_from_url, in both the async and sync clients.Second problem: the class derived from
Exception, notAuthError. Soexcept AuthErrordid not catch it, unlike every other auth error in the module.The change
UserDoesntExistnow takes no arguments and passes a fixed, non-secret message tosuper().__init__.CustomAuthError(status 404, codeuser_not_found), so it joins the documented hierarchy._asyncand the generated_synctwin.src/auth/tests/test_errors.pyfails if the token comes back throughargs,str(), or an attribute. It needs no docker infra.Breaking change
UserDoesntExist()takes no arguments, and the.access_tokenattribute is gone. Nothing in this repo read that attribute. Callers who construct the error or read the token must update.Note for the reviewer
I did not run
make build-syncin the commit. The local black/ruff reflows about ten unrelated blocks in the generated_syncfiles, which would bury the real change. I applied the same two-line edit to_sync/gotrue_client.pyby hand instead. The formatting drift is worth a separate fix.Checks
pytest src/auth/tests/test_errors.pypasses.mypyclean on the changed files.ruff checkandruff format --checkclean on the changed files.