unsloth/studio/backend/plugins
Tai An b364080225
fix(gh_client): fail fast on 401/403 auth errors instead of retrying forever (#5325) (#5329)
* fix(gh_client): fail fast on 401/403 auth errors instead of retrying forever (#5325)

Fixes #5325. The Studio data-recipe GitHub Crawler swallows 401 Unauthorized
(and 403 Forbidden without rate-limit headers) into the generic
"network error" retry path, so a job with a stale or wrong-scoped GitHub
token spins indefinitely emitting "Retry." lines until the user cancels.

Changes:

- Add GitHubAuthError. Raised on 401, and on 403 unless the response carries
  a clear rate-limit signal (Retry-After header for secondary limits, or
  X-RateLimit-Remaining: 0 for primary limits).
- Track which token source resolved at construction time: explicit argument
  (recipe-level field), GH_TOKEN, or GITHUB_TOKEN. Surfaced in the error
  message so the user knows which credential to rotate.
- Insert the auth-failure check before the existing 403/429 rate-limit branch
  in both .graphql() and .rest() so auth failures bypass the sleep-and-retry
  loop and abort the recipe immediately.

Genuine rate limiting still retries via the existing path. requests.RequestException
handling is unchanged because GitHubAuthError does not inherit from it.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* style: apply black formatting per pre-commit.ci

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fix GitHub auth failure handling

Preserve GitHub token source through the repo seed scraper and fail fast on non-rate-limit auth errors while keeping genuine rate-limit retries.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Wasim Yousef Said <wasimysdev@gmail.com>
2026-05-08 21:57:41 +04:00
..
data-designer-github-repo-seed fix(gh_client): fail fast on 401/403 auth errors instead of retrying forever (#5325) (#5329) 2026-05-08 21:57:41 +04:00
data-designer-unstructured-seed Bump Data Designer to 0.5.4 (removes litellm dependency) (#4569) 2026-03-25 02:01:43 -07:00
__init__.py Final cleanup 2026-03-12 18:28:04 +00:00