Skip to content

Fix stale auth handling in login and status#191

Merged
khaliqgant merged 1 commit into
mainfrom
codex/issues-188-189
May 21, 2026
Merged

Fix stale auth handling in login and status#191
khaliqgant merged 1 commit into
mainfrom
codex/issues-188-189

Conversation

@khaliqgant
Copy link
Copy Markdown
Member

Summary

  • clear stale counterpart credential files when login switches between cloud and legacy API-key auth flows
  • add relayfile status auth diagnostics for expired cloud sessions, expiring access tokens, and daemons started before the latest credential write
  • map sync-status 401 responses to the existing re-login hint error

Fixes #188
Fixes #189

Tests

  • go test ./cmd/relayfile-cli
  • go test ./...

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 21, 2026

Warning

Rate limit exceeded

@khaliqgant has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 39 minutes and 37 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: ac7deddc-12b8-4a28-9bca-2ea1ae33a664

📥 Commits

Reviewing files that changed from the base of the PR and between b4f4006 and 3439248.

📒 Files selected for processing (3)
  • .trajectories/index.json
  • cmd/relayfile-cli/main.go
  • cmd/relayfile-cli/main_test.go
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/issues-188-189

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown

Relayfile Eval Review

Run: .relayfile/evals/runs/2026-05-21T13-23-35-891Z-HEAD-provider
Mode: provider
Git SHA: 58697bc

Passed: 4 | Needs human: 0 | Reviewable: 0 | Missing output: 0 | Failed: 0 | Skipped: 0

Human Review Cases

No reviewable human-review cases captured Relayfile output.

@khaliqgant khaliqgant merged commit 04dd0d3 into main May 21, 2026
9 of 10 checks passed
@khaliqgant khaliqgant deleted the codex/issues-188-189 branch May 21, 2026 13:27
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 1 potential issue.

View 5 additional findings in Devin Review.

Open in Devin Review

Comment thread cmd/relayfile-cli/main.go
Comment on lines +1866 to +1868
if err := removeCredentialFile(credentialsPath()); err != nil {
fmt.Fprintf(stdout, "warning: could not clear stale server credentials: %v\n", err)
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔴 --skip-workspace-refresh deletes existing server credentials despite user opting out of workspace changes

The new removeCredentialFile(credentialsPath()) call at cmd/relayfile-cli/main.go:1866 runs unconditionally after the if !*skipWorkspace { ... } block (lines 1843–1864). When --skip-workspace-refresh is true, the entire workspace-refresh block is skipped, so execution falls straight through to line 1866 which deletes the server credentials file.

This breaks the following workflow:

  1. User runs relayfile setup → workspace created, server credentials saved
  2. User runs relayfile login --skip-workspace-refresh → intends to only refresh cloud auth
  3. Server credentials (workspace token) are deleted
  4. Subsequent commands like relayfile status or relayfile mount fail with "credentials not found"

The flag's documented semantics are "sign into the cloud only; do not refresh the workspace token" — removing the workspace token violates this contract. The existing test TestLoginSkipsWorkspaceRefreshWhenFlagSet doesn't catch this because it never pre-saves server credentials before running the command.

Prompt for agents
In runLogin (cmd/relayfile-cli/main.go), the removeCredentialFile(credentialsPath()) call at line 1866 runs even when *skipWorkspace is true, which deletes the user's existing workspace token despite them explicitly opting out of workspace changes via --skip-workspace-refresh.

The fix should guard the credential removal so it only runs when the cloud flow actually attempted (and failed) a workspace refresh. One approach: wrap the removal in an if !*skipWorkspace check, or move it inside the existing if !*skipWorkspace block (after line 1864, before the closing brace). The setup message on line 1869 should probably also be guarded by the same condition, since telling a --skip-workspace-refresh user to run relayfile setup is confusing when they already have a workspace.

Also update TestLoginSkipsWorkspaceRefreshWhenFlagSet to pre-save server credentials and verify they survive the login command.
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

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.

relayfile status does not surface "needs re-login" / stale auth state relayfile login only refreshes one of two credential files

1 participant