Skip to content

fix(management): retry transient Devin OAuth callback read errors - #13

Merged
jiroamato merged 1 commit into
mainfrom
fix/devin-oauth-callback-read-retry
Nov 12, 2026
Merged

jiroamato merged 1 commit into
mainfrom
fix/devin-oauth-callback-read-retry

Conversation

@jiroamato

@jiroamato jiroamato commented Nov 12, 2026 •

Copy link
Copy Markdown
Owner

Devin logins on Windows could fail with "Failed to read OAuth callback" even after the callback arrived. This backports the fix from upstream PR router-for-me#7482 so the fork has it before upstream merges.

The callback handler writes a temp file and renames it into place. On Windows, a read of that path during the rename fails with a sharing violation. waitDevinOAuthCallback treated every read error except not-exist as fatal and ended the login. It now retries on the next 500ms tick, as the Claude, Codex and Antigravity flows already do. The context deadline and the session state still end the wait.

TestWaitDevinOAuthCallbackRetriesTransientReadError covers the fix and fails on the old code. TestDevinRemoteOAuthFlow now prints the session status when the token exchange does not start, and its 5s failure bounds are 15s.

The two files match the upstream PR head exactly, so the next upstream sync merges cleanly. #12 had its own 5s to 15s bump in the same test. I dropped it there, and the two PRs merge cleanly in either order.

go build, go vet and the management package tests pass on Windows. The Devin tests passed 20/20 in a loop.

Summary by CodeRabbit

  • Bug Fixes
    • Devin sign-in now retries when a temporary issue prevents reading the OAuth callback, helping the login flow continue when the callback becomes available.
    • OAuth callback handling still reports invalid callback data, and the wait for a callback remains limited by the session state and timeout.

waitDevinOAuthCallback ended the login with "Failed to read OAuth callback"
on any read error other than not-exist. On Windows a read that lands while the
callback handler renames the file into place fails with a sharing violation,
so a login could fail although the callback arrived. Retry on the next tick,
as the other OAuth flows already do. The context deadline and session state
still bound the wait.

This was the cause of the intermittent "token exchange did not start" in
TestDevinRemoteOAuthFlow. The test now reports the session status on that
failure, and its 5s failure bounds are 15s.

Backport of upstream router-for-me#7482 (a50f54e), with the Devin
test bound change from 97b8a03 that the regression test depends on.
@coderabbitai

coderabbitai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The Devin OAuth callback wait now retries file-read errors. Tests cover a transient read error and use longer bounds for token-exchange and login-completion waits.

Changes: Devin OAuth callback handling

Layer / File(s) Summary
Retry callback file reads
internal/api/handlers/management/auth_files_devin_oauth.go
The callback file reader is now overridable. The wait retries file-read errors and continues to decode successful reads, while invalid JSON still returns "Invalid OAuth callback".
Test retries and OAuth wait bounds
internal/api/handlers/management/auth_files_devin_oauth_test.go
Tests verify success after one transient read error and use 15-second bounds for token exchange and login completion. The token-exchange timeout reports the OAuth session status.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related PRs

  • jiroamato/CLIProxyAPI#12: Changes the token-exchange and login-completion waits in the same test from 5 seconds to 15 seconds.

Suggested reviewers: ltbinglingfeng, luispater

Merge Risk: Minimal · up to 1088c

The change makes Devin OAuth login more tolerant of transient callback-file read errors, such as those caused by a rename on Windows. The wait remains bounded by the existing deadline. No merge-blocking risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: waitDevinOAuthCallback now retries transient callback-file read errors instead of failing the login. It also carries the conventional fix(management) scope. The change…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: waitDevinOAuthCallback now retries transient callback-file read errors instead of failing the login. It also carries the conventional fix(management) scope. The changeset matches this: the read-error path in auth_files_devin_oauth.go now retries, and a new test covers the retry after a transient read error.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: aea72526-7ed1-4851-ac44-2d2a00b2bdd5
Commits

Reviewing files that changed from the base of the PR and between 4a544cb and 1088c7e.

Files selected for processing: 2

  • internal/api/handlers/management/auth_files_devin_oauth.go
  • internal/api/handlers/management/auth_files_devin_oauth_test.go

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@greptile-apps

greptile-apps Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] This PR appears safe to merge.

Summary

Devin OAuth now retries callback-file read errors instead of ending the login immediately.

  • Devin logins retry callback-file read errors and continue.

Reviews (1) · Last reviewed commit: "fix(management): retry transient Devin O..." · Reviewed by Greptile

@jiroamato
jiroamato merged commit 42a09cb into main Nov 12, 2026
3 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.

1 participant