Skip to content

Conversation

@nthmost-orkes
Copy link

Bug Fix

Fixes AttributeError: 'ApiClientAdapter' object has no attribute 'auth_401_handler'

Reported Error:

ERROR: Failed to get new token, reason: ("'ApiClientAdapter' object has no attribute 'auth_401_handler'",)

Root Cause

During ApiClientAdapter.__init__, the code was calling __refresh_auth_token() before initializing auth_401_handler. When authentication settings are configured, __refresh_auth_token() calls call_api('/token'), which requires auth_401_handler to exist.

Why This Affected Some Deployments But Not Others

This bug only occurs when:

  1. Authentication settings are configured (key_id and key_secret are set)
  2. No existing AUTH_TOKEN is present (first initialization or token expired)

Many deployments didn't hit this because they either:

  • Had valid tokens cached from previous sessions
  • Used authentication methods that don't trigger token refresh during init
  • Encountered the error but it didn't affect operation (token fetch failed silently in some cases)

When Bug Was Introduced

Introduced in commit 1f57c1e7 (October 13, 2025) when the 401 exponential backoff feature was added.

Changes

  1. Reordered initialization: Move auth_401_handler setup before __ensure_auth_token() call
  2. Renamed method: __refresh_auth_token__ensure_auth_token for clarity (it initializes, doesn't refresh)
  3. Added documentation: Clear docstrings explaining initialization vs refresh behavior

Testing

  • All 17 existing unit tests pass
  • Verified fix with authentication settings that trigger token fetch during init

IgorChvyrov-sm and others added 27 commits October 3, 2025 14:36
@nthmost-orkes nthmost-orkes requested a review from v1r3n November 10, 2025 19:30
Copy link
Contributor

@v1r3n v1r3n left a comment

Choose a reason for hiding this comment

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

this is on top of the changes we decided to not push to prod anymore.

@nthmost-orkes
Copy link
Author

nthmost-orkes commented Nov 13, 2025 via email

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.

5 participants