Skip to content

Apply optional token_refresh_failed fallback in with_api/4#198

Merged
maennchen merged 1 commit into
hexpm:mainfrom
maennchen:jm/with-api-optional-token-refresh-failed
Jun 16, 2026
Merged

Apply optional token_refresh_failed fallback in with_api/4#198
maennchen merged 1 commit into
hexpm:mainfrom
maennchen:jm/with-api-optional-token-refresh-failed

Conversation

@maennchen

Copy link
Copy Markdown
Member

Summary

with_repo/3 falls back to executing without credentials when resolve_repo_auth returns {auth_error, token_refresh_failed} and optional is true. with_api/4 was missing the equivalent handling, so an optional API call would surface the refresh failure as an error instead of proceeding anonymously.

This adds the matching clause to with_api/4, placed before the catch-all error clause so non-optional calls still propagate the error.

Addresses hexpm/hex#1143 (comment).

When resolve_api_auth/2 fails with token_refresh_failed and optional is
true, fall back to executing the request without credentials, mirroring
the existing handling in with_repo/3.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@maennchen maennchen merged commit e093545 into hexpm:main Jun 16, 2026
10 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