Add structured JSON next_steps to workflow commands and a global JSON error envelope#1282
Open
no-itsbackpack wants to merge 4 commits into
Open
Add structured JSON next_steps to workflow commands and a global JSON error envelope#1282no-itsbackpack wants to merge 4 commits into
no-itsbackpack wants to merge 4 commits into
Conversation
… error envelope.
Workflow commands (create, cutover, cancel, switch-traffic, etc.) now return
status/issues/next_steps JSON with contextual remediation commands in --format
json mode. Unhandled errors on any command now fall back to a classified
{status, code, error, next_steps} envelope on stdout instead of a bare
{"error"} blob on stderr.
Co-authored-by: Cursor <cursoragent@cursor.com>
…ommands. Auth failures (expired token, not authenticated) surfaced through workflow subcommands now report NO_AUTH with login next_steps instead of a generic WORKFLOW_ERROR, matching the remediation agents get on any other command. Co-authored-by: Cursor <cursoragent@cursor.com>
A bare "timeout" substring match swallowed operation and deadline timeouts (e.g. workflow cutover timeouts), giving agents connectivity remediation instead of command-specific next_steps. Match specific transport error strings (i/o timeout, TLS handshake timeout, connection refused/reset, no such host) instead. Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 2cac4d5. Configure here.
…mmands The JSON confirmation envelope replaced the old Format() != Human guard, which let --format csv fall through to interactive confirmation on a TTY for cancel, cutover, and switch-traffic. Reinstate the format error after the JSON branch so non-JSON machine formats fail fast without --force. Co-authored-by: Cursor <cursoragent@cursor.com>
mscoutermarsh
approved these changes
Jul 8, 2026
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.

Summary
Continues the agent-onboarding work from #1280: agents driving
pscale --format jsonnow get actionable, machine-readable remediation on the error path for workflow commands (e.g. move-tables) and on every other command via a global fallback envelope.Workflow commands
internal/cmd/workflow/json.go: sharedstatus/error/issues/next_stepserror responses carrying real org/database/branch/workflow values, not placeholders.workflow createvalidates--source-keyspace/--target-keyspace/--tablesup front and returnsMISSING_FLAGSwith akeyspace listdiscovery command plus a filled-increateexample.cutover,cancel,switch-traffic) without--forcereturnaction_requiredwith an approval prompt and the exact--forceretry command (including--replicas-onlywhen set), instead of a bare "cannot ... with output format json" error.NOT_FOUND/WORKFLOW_ERRORwith discoverynext_steps(database list,workflow list,workflow show).Global JSON error envelope
cmdutil.ReportGlobalJSONError: any command failing in--format jsonmode without its own structured JSON now emits a classified{status, code, error, next_steps}envelope on stdout, replacing the old{"error": "..."}blob on stderr.NO_AUTH,SERVICE_TOKEN_INVALID,INVALID_FLAG_PLACEMENT,INVALID_USAGE,UNKNOWN_COMMAND,UNKNOWN_FLAG,TTY_REQUIRED,CONFIRMATION_REQUIRED,NOT_FOUND,NETWORK_ERROR, withCOMMAND_FAILEDas fallback. Each case lists only steps that address that failure — usage errors do not suggest re-authenticating.action_requiredclassifications exit 1; everything else exits 2 (or the command's own exit code).pscale --orgmistake now flows through the same classifier in JSON mode; the human-mode hint is unchanged.Also
Agent*Cmdhelpers incmdutil/agent_steps.gofor workflow/keyspace commands; deduplicated placeholder rendering.errors.Astoerrors.AsTypein touched files.Commands that already return structured JSON (
auth,sql,mcp install,agent-guide) are unchanged. Success output shapes are unchanged everywhere — no breaking changes for existing JSON consumers.Test plan
go test ./internal/cmdutil/... ./internal/cmd/workflow/... ./internal/cmd/sql/... ./internal/cmd/auth/... ./internal/cmd/agentguide/...go vet+staticcheckclean oninternal/cmdutilandinternal/cmdgofmtcleanpscale workflow cutover <db> <n> --org <org> --format json(no--force) returnsCONFIRMATION_REQUIREDwith retry commandpscale database list --format jsonreturnsNO_AUTHenvelope on stdout