Skip to content

Handle refresh token exception - #449

Merged
Danielhiversen merged 1 commit into
Danielhiversen:masterfrom
MartinHjelmare:handle-refresh-token-exception
Aug 22, 2026
Merged

Handle refresh token exception#449
Danielhiversen merged 1 commit into
Danielhiversen:masterfrom
MartinHjelmare:handle-refresh-token-exception

Conversation

@MartinHjelmare

Copy link
Copy Markdown
Contributor

The callback is defined outside of this library so we need to handle exceptions when calling it.

@augmentcode

augmentcode Bot commented Aug 17, 2026

Copy link
Copy Markdown
🤖 Augment PR Summary

Summary: Makes realtime reconnects tolerate failures from user-supplied access-token refresh callbacks.

Changes:

  • Wraps the top-level Tibber refresh callback invocation in exception handling.
  • Logs callback failures and continues the reconnect flow without a refreshed token.
  • Adds a regression test that verifies a failed callback does not prevent transport reconstruction.

Technical Notes: Successful refresh behavior, including synchronizing a changed token with the data API, remains unchanged.

🤖 Was this summary useful? React with 👍 or 👎

@augmentcode augmentcode Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review completed. 1 suggestion posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

Comment thread tibber/__init__.py
access_token = await self._refresh_access_token()
try:
access_token = await self._refresh_access_token()
except Exception:

@augmentcode augmentcode Bot Aug 17, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

TibberRT is also an exported public class and accepts refresh_access_token directly, but its reconnect() still awaits that callback unguarded at tibber/realtime.py:154. Consequently, direct TibberRT users still have reconnect abort when their externally defined callback raises, despite the behavior this change intends to provide.

Severity: medium

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

@MartinHjelmare MartinHjelmare Aug 17, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don't think TibberRT is expected to be called separately, but in any case I think that's a separate problem.

@Danielhiversen
Danielhiversen merged commit b80a9cf into Danielhiversen:master Aug 22, 2026
4 checks passed
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.

2 participants