fix(cli): surface actionable errors for cloud-mode setup failures - #1058
Open
danfinn5 wants to merge 1 commit into
Open
fix(cli): surface actionable errors for cloud-mode setup failures#1058danfinn5 wants to merge 1 commit into
danfinn5 wants to merge 1 commit into
Conversation
When a user picks Cloud mode during `pad init` but doesn't have a Pad Cloud account, the CLI hits the cloud server and surfaces raw server errors like "Missing CSRF token" — which is an implementation detail that gives no indication of what went wrong or how to fix it. This patch: - Splits the ModeCloud and ModeRemote branches in printSetupRequiredHint so cloud users see "sign up or switch to local" instead of the generic "run pad auth setup on the server" message. - Returns a cloud-specific error from pad init when setup_required is true in cloud mode. - Intercepts csrf_error responses in the CLI HTTP client and replaces the raw server message with an actionable "run pad auth login" message, since the CLI never sends CSRF cookies and this error always indicates a stale or mismatched session.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
When a user picks Cloud mode during
pad initbut hasn't signed up for Pad Cloud, the CLI hitsapp.getpad.devand surfaces raw server errors -- typically "Missing CSRF token" -- instead of telling the user what actually went wrong. This happened to me on a fresh Fedora 43 install; I spent a while debugging what I assumed was a server-side CSRF bug before realizing the CLI was talking to a remote server I had no account on.Three small changes:
printSetupRequiredHintnow has a dedicated Cloud branch -- tells the user to sign up atapp.getpad.dev/registeror switch to local mode, instead of the generic "runpad auth setupon the server" message.pad initreturns a cloud-specific error ("Pad Cloud account required") whensetup_requiredis true in Cloud mode.csrf_errorresponses and replaces the raw server message with "Session authentication error. Runpad auth loginto re-authenticate." The CLI uses Bearer auth exclusively, so acsrf_erroralways indicates a session state problem, not something the user can act on directly.Closes #1057
How to test
pad auth configure --mode cloud(or pick Cloud duringpad init)pad initChecklist
make buildpassesmake testpasses