Skip to content

fix(session): forward session resolution errors as StreamEvent#33

Merged
galuszkm merged 2 commits into
mainfrom
copilot/fix-sso-token-expired-error
Jun 28, 2026
Merged

fix(session): forward session resolution errors as StreamEvent#33
galuszkm merged 2 commits into
mainfrom
copilot/fix-sso-token-expired-error

Conversation

Copilot AI commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

When resolve_session() raises (e.g. botocore.exceptions.TokenRetrievalError from expired AWS SSO credentials), the exception previously propagated unhandled out of the invoke() generator, ending the stream abruptly with no error event emitted to the client.

Changes

  • app.py — wrap resolve_session() in try/except Exception; on failure log via logger.exception() and yield an error StreamEvent before returning. app.state.session is only updated on success.
try:
    session = resolve_session(app.state.app_config, app.state.infra, session_id)
except Exception as exc:
    logger.exception("session_id=<%s> | session resolution failed", session_id)
    yield error_event(str(exc)).asdict()
    return
app.state.session = session
  • test_app_invoke.py — adds test_yields_error_event_when_resolve_session_raises to assert that a single error event is emitted and app.state.session remains None when resolution fails.

Wrap the resolve_session() call in the invoke() generator with a
try/except block so that any exception raised during session resolution
(e.g. botocore.exceptions.TokenRetrievalError from expired AWS SSO
tokens) is caught, logged via logger.exception(), and forwarded to the
client as an error StreamEvent. Previously the exception propagated
unhandled, ending the stream abruptly with no error feedback.

Closes #32
Copilot AI changed the title [WIP] Fix SSO token expired error not forwarded as StreamEvent fix(session): forward session resolution errors as StreamEvent Jun 28, 2026
Copilot AI requested a review from galuszkm June 28, 2026 12:09
@galuszkm galuszkm marked this pull request as ready for review June 28, 2026 12:12

@galuszkm galuszkm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@galuszkm galuszkm merged commit 55f7f88 into main Jun 28, 2026
7 checks passed
@galuszkm galuszkm deleted the copilot/fix-sso-token-expired-error branch June 28, 2026 12:12
@galuszkm galuszkm linked an issue Jun 28, 2026 that may be closed by this pull request
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] SSO Token Expired Error Not Forwarded as StreamEvent

2 participants