Skip to content

Better observability for errors in token refresh#782

Open
makhalin wants to merge 3 commits intoydb-platform:mainfrom
makhalin:makhalin-patch-1
Open

Better observability for errors in token refresh#782
makhalin wants to merge 3 commits intoydb-platform:mainfrom
makhalin:makhalin-patch-1

Conversation

@makhalin
Copy link

The current logging behavior for problems in token refresh doesn't have enough information. This resulted in us getting a line in the logs like Failed to refresh token async: , which is impossible to understand. This MR suggests improving this section and displaying the log with a full traceback.

You can read about exc_info in the official doc https://docs.python.org/3/library/logging.html#logging.Logger.debug.

Pull request type

Please check the type of change your PR introduces:

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes
  • Other (please describe):

What is the current behavior?

Issue Number: N/A

No traceback is printed in logs.

What is the new behavior?

The full traceback of an error is printed in logs.

Other information

@vgvoleg
Copy link
Collaborator

vgvoleg commented Mar 18, 2026

Hi @makhalin ! thanks for this PR. can you create an Issue for this PR and link it in PR description?

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Improves error observability during credential token refresh by ensuring exception tracebacks are included in logs, making refresh failures diagnosable in production.

Changes:

  • Include exception traceback when sync token refresh fails (exc_info=True).
  • Include exception traceback when async token refresh fails (exc_info=True).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
ydb/credentials.py Adds traceback logging on token refresh failure in sync credentials flow.
ydb/aio/credentials.py Adds traceback logging on token refresh failure in async credentials flow.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

except Exception as e:
self.last_error = str(e)
self.logger.error("Failed to refresh token: %s", e)
self.logger.error("Failed to refresh token: %s", e, exc_info=True)
except Exception as e:
self.last_error = str(e)
self.logger.error("Failed to refresh token async: %s", e)
self.logger.error("Failed to refresh token async: %s", e, exc_info=True)
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.

3 participants