Py/client: re-open session via rpc if id is provided, fallback to create new#160
Merged
Conversation
hon-gyu
commented
May 26, 2026
Comment on lines
+14
to
+24
| def is_session_not_found(ex: TwirpServerException) -> bool: | ||
| # TODO: | ||
| # The server currently surfaces an expired/missing session as a generic | ||
| # internal error; the only stable signal is the substring in the body | ||
| # message. The phrasing differs between RPCs: | ||
| # - SessionManager.open_session -> "Unknown session" | ||
| # - other session-bearing RPCs -> "Session not found" | ||
| # Replace with a typed code check once the server is updated. | ||
| body = (getattr(ex, "meta", None) or {}).get("body") or {} # type: ignore | ||
| msg = body.get("msg") or "" # type: ignore | ||
| return "Session not found" in msg or "Unknown session" in msg |
Contributor
Author
There was a problem hiding this comment.
This is a temporary workaround because the server currently surfaces an expired/missing session as a generic internal error; the only stable signal is the substring in the body message.
Collaborator
There was a problem hiding this comment.
Yep, this needs a server-side fix as well, I'll add a new error kind for it.
e442d34 to
50d9320
Compare
wintersteiger
approved these changes
May 29, 2026
wintersteiger
left a comment
Collaborator
There was a problem hiding this comment.
LGTM, many thanks! The new error kind is merged here and in imandrax (dev), so we could start checking for that one any time now too.
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 #159 on client side
Note: #159 points out a server side issue that the session not found error is returned untyped (as
GeneraIOError) containing ocaml trace. I think this should be fixed as well