Skip to content

Create OAuth token lazily to fix asset precompilation - #8

Open
trobiyo wants to merge 1 commit into
CERN:masterfrom
trobiyo:fix/lazy-oauth-token
Open

trobiyo wants to merge 1 commit into
CERN:masterfrom
trobiyo:fix/lazy-oauth-token

Conversation

@trobiyo

@trobiyo trobiyo commented Oct 28, 2026

Copy link
Copy Markdown
Collaborator

The poller is instantiated in after_initialize, which also runs during assets:precompile with SKIP_DB_AND_REDIS=1. There the refresh token site setting is blank, and oauth2 >= 2.0.25 raises "OAuth2::AccessToken has no token" when constructing a token without a token or refresh token, breaking the Discourse image build.

Build the access token on first poll instead, and only cache it after a successful refresh so a corrected refresh token setting is picked up on the next poll. Failures are logged by the existing rescue in poll_mailbox.

The poller is instantiated in after_initialize, which also runs during
`assets:precompile` with SKIP_DB_AND_REDIS=1. There the refresh token site
setting is blank, and oauth2 >= 2.0.25 raises "OAuth2::AccessToken has no
token" when constructing a token without a token or refresh token, breaking
the Discourse image build.

Build the access token on first poll instead, and only cache it after a
successful refresh so a corrected refresh token setting is picked up on the
next poll. Failures are logged by the existing rescue in poll_mailbox.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant