Repository navigation
feat: errors that teach, plus usability-sweep fixes (stacked on #55) - #56
Open
Bradenream wants to merge 30 commits into
Open
Bradenream wants to merge 30 commits into
Bradenream wants to merge 30 commits into
Conversation
client.WithSpinnerMessage puts a message on a request's context, which the spinner shows in place of what the command does. A picker loading your workspaces before environment publish runs should say "Loading your workspaces…", not "Publish environment…".
The form asked for every missing ID as free text, so a person had to find and paste one. It can now offer a list instead, for any flag with a registered Picker: - What an ID depends on is picked first: a project after its workspace, even when the command has no --workspace-id, an environment after its project. - A lone choice is taken and said so, unless the command changes or removes what it picks (delete, publish, merge, update…). - The last pick comes first, where Enter takes it again; it is never taken without asking. It is kept in ~/.config/vf/picks.json (owner-only). - "Type an ID…" ends every list, and a list that fails or comes back empty says so and asks for the ID, as before. PromptAndSetFlags calls pickRequired after its header, so pickers run only where the form does: never in agent mode, a pipe or --no-interactive.
Registers the four pickers most commands need: --project-id is required by
252 of 273 commands and --environment-alias by 197.
Organizations come from the workspace list, since the API has no
organizations endpoint and no organization names: each is named by its
workspaces ("Acme, Support +2 more"). Workspaces say which org they are
in when there is more than one; environments are picked by alias, with
the main one marked.
Tests run against a fake API server; none lists a real account.
An API error printed its raw JSON body, then a generic hint that told
everyone with a 401 or 403 to run 'vf auth login', 'vf auth signup' or
'vf configure'. A signed-in user whose browser session was refused, as
when creating a workspace without an admin role, was told to sign in
again; a 403 got the same advice; and the hints the SDK hook injected
said personal keys expire, which a session does not.
internal/output/explain.go now decides what every failure says: what
happened, why, and what to do next, drawn per internal/ui/DESIGN.md:
✗ Couldn't get project · HTTP 404 Not Found
⎿ Project not found
Check --project-id p1: it may be wrong, or belong to another
workspace or environment.
Next:
vf project list lists the IDs you can use
Docs: https://www.voiceflow.com/docs/cli/commands/project
- A 401 is explained by the credential sent: a key from --token, a
VF_TOKEN that outranks the session, or a current browser session,
which makes it a permission problem.
- 402 links the add-credits page; 409, 429 (Retry-After), 5xx, an
undocumented status and an unreadable response each say why and what
next; field errors name their flag.
- Timeouts, DNS failures, refused connections and TLS failures say
which, and name the server URL when it was overridden. They used to
be classified as connection errors with "check network connectivity",
including a response vf could not decode.
- Not signed in leads with 'vf auth login'; Settings → Personal keys
replaces the old Access tokens name.
- Agents get the same content in the envelope: explanation, hints and
docs_url, with a server's own hints winning.
The SDK hook keeps the no-credential preflight and the malformed-token
warnings; its per-status hints move into explain.go, which knows the
command, its flags and the credential.
A --jq that did not parse was found only when Result applied it, after the request had run: 'vf variable create … --jq ".["' created the variable, then failed, and running it again made a second one. An unknown --output-format was never reported; Result fell through to its YAML-like default and exited 0. PrepareCallOpts, which every operation calls before it sends, now rejects both. The filter is compiled as well as parsed, which also catches a function that does not exist.
Everything that fails around a request rather than in its response
reached main.go as a bare string, the same in both modes:
"unknown flag: --nosuch", with no command named and no way on;
"missing required flag: --project-id", with no word on where to find
one. Agents got prose where they expect an envelope. And a word a
command group does not know, 'vf workspace lsit', printed the group's
help and exited 0.
internal/cli/errors.go explains them the way output.Error explains API
errors, drawn for a person or written as JSON in agent mode:
- Unknown commands and flags suggest the nearest ("Did you mean
'vf workspace list'?", "Did you mean '--name'?") and name --help.
- A group given a word it does not know fails, with a suggestion.
- A missing flag says why vf did not ask (agent mode, --no-interactive,
not a terminal), names the list command that shows its values
('vf project list'; organizations are on 'vf workspace list'), and
says a terminal would have offered a picker.
- A flag with no value or a value it cannot parse, a bad --timeout,
--jq, --output-format or -H, a broken config file, configure or login
with --no-interactive and nothing to save, --email without signup:
each names its fix.
- An ended or unrenewable browser session says so and says to sign in
again; oauth exports ErrSessionEnded and ErrRenewSession for it.
- A canceled form reports "Canceled", as the home prompt already did.
- The configure and login agent hints name VF_TOKEN and 'vf auth login'
rather than "environment variables (prefix: VF_)".
The home prompt reports a line's error the same way, and a picker whose
list fails says why in one line (output.ShortReason).
DESIGN.md gets an Errors section: the ✗ line, the cause under ⎿, next steps with commands in Accent, docs in Muted, the plain form off a terminal and the JSON fields in agent mode. The READMEs pointed at Settings → Access tokens, which the Voiceflow docs now call Personal keys; the npm README also leads with 'vf auth login'.
A 401 to a current browser session, or a 403, comes with no reason, and the API has no endpoint for organizations or roles. So the explanation was a guess: "most likely your account isn't allowed to do this in the workspace or organization it targets". Now vf looks the target up in your workspaces, the one request an error makes, and says which organization or workspace was refused and whether you're in it: It targeted organization o1 (Acme, Support). You're in 2 of its workspaces, so you're a member, but your role in the organization most likely doesn't allow this. A member is told to ask an owner or admin of that organization; someone with no workspace in it is told to check the ID. A refused key is still a bad key (no lookup), and a picker's one-line warning skips it. The picker list calls now send the command's -H headers too, as the command's own request does.
The home prompt forgot everything between lines: after 'project create' the next command asked for the project again, from a list, as if nothing had happened. The best CLIs keep you at the prompt but carry what you were working on forward: gcloud's current project, kubectl's context, psql's \c. Now what you create or pick in the prompt becomes current (internal/session), for the four levels the pickers know: organization, workspace, project, environment. - A command that needs one uses the current one and says so: "✓ Using project Help bot (p1), the current one". A command that changes or removes what it picks still shows the list, the current one first, so nothing is deleted unseen. - The prompt box's top border shows it: ╭─ workspace Acme › project Help bot ─╮ - 'use' shows it, 'use project' picks a new one, 'use clear' drops it. - Changing a level clears the narrower ones, and deleting the current one forgets it. - It lives only as long as the prompt: a one-shot vf command and agent mode never see it. A create now ends the way the best CLIs end one, wherever pretty output reaches a person: a "✓ Created project Help bot (p1) in workspace Acme" line, the result, then Next: steps. In the prompt the steps leave out the IDs the context fills in; elsewhere they carry them. JSON, --jq, agent mode and a pipe get the result alone.
The empty prompt always suggested 'workspace list', even right after creating a project, where the useful next step is working in it. The placeholder now follows the context: 'agent read-instructions' with a current project (the first of a new project's next steps), 'project list' with a workspace, 'workspace list' with nothing, and 'auth login' signed out. Each runs as suggested: the context fills its IDs.
Signed in with nothing current, the empty prompt suggested 'workspace list'. It now suggests 'project create': making a project is the first thing a signed-in user does, and the picker finds its workspace. Signed out still suggests 'auth login'.
Making a project is now the default first step everywhere a signed-in
person starts: the banner's "Get started" leads with 'vf project create'
in place of 'vf workspace list', and the empty prompt suggests it with a
workspace current, as it already did with nothing current. Once a project
is current the prompt suggests working in it ('agent read-instructions').
… change something The form asked "Fill in N optional field(s)?" after the required ones on every command, reads included. 'agent read-instructions' with a current project and a lone environment filled both required fields itself, then stopped to ask whether to page with --offset and --limit: the one question it asked was about fields no one needed. Now only a command that makes or changes something (create, update, patch, add, set, replace, clone, duplicate, insert, link, move, split, reorder, arrange, assign, merge, publish, connect) offers them, where they matter: a description on create, the field to change on update, where every one is optional. Reads, lists, searches, deletes and runs never ask, and the header no longer counts optional fields it won't ask for. The flags are still there for whoever wants them.
A read in the home prompt asked which environment to use every time, and
its menu listed flags vf was about to fill as "required".
- Commands that don't change environments take the project's main one,
with a status line; edits go to its draft and only publishing goes
live. Publish, merge, delete and update still ask, main first.
- When vf can fill every required flag (from what is current, a default
or a list), the menu stays shut after the command: the footer says
"enter to run · tab or - for flags", and Enter runs it. Tab or a dash
opens it, where a filled flag says with what ("uses Help bot
(current)", "uses the main one by default", "you pick it from a list").
- The form's header prints before the first list or field that asks,
never over picks taken without asking.
agent read-prompt, agent read-instructions and playbook read-instructions
printed the API's page for agents as YAML: each line numbered in the
string color, long lines wrapping to column 0, markdown raw, and six
fields about the page.
At a terminal, in pretty output, the page now reads as a document:
- No line numbers; editing works by exact text, so a person needs none.
- Markdown rendered in vf's colors by a small renderer (ui/markdown.go)
that hides nothing written: headings lose their #s, bullets become •,
bold and italic are styled, backticked names and {variables} are
Accent, and XML tags like <role> stay, Subtle. Code blocks and table
rows are left as written; without color the markers stay. glamour was
ruled out: it drops XML tags, runs lines together, and adds 10 MB.
- Every line stays a line; only one wider than the box is reflowed,
under its own indent or bullet.
- One line about the page: "18 lines · 980 characters", or "Lines 1–400
of 1,203 · vf agent read-prompt … --offset 401 for more", then the
API's note on links.
JSON, YAML, --jq, agent mode and a pipe get the page as the API sent it.
Picking an older project (v3, made before environments) for agent read-instructions printed only "Couldn't list your environments: HTTP 404 Not Found — Project does not have any environments", without saying which project, then asked for an "Environment ID" that couldn't exist. - A pick or a typed ID is said once its form has gone: "✓ Using project Old bot (pold)". - A list that answers 404 for what it lists from (a project with no environments) stops the command instead of asking for an ID. In the home prompt that project stops being current. - The public API doesn't say what kind a project is, so its refusals are read (output/framework.go): a 404 "Project does not have any environments" explains the fixed development, staging and production versions and points to Migrate to environments; a 400 "is not an agent project" explains Conversation Flow and points to the Agentic framework switch. Both offer another project first. - A message the API wrote for an AI agent is said to the person: "Tell the user that X" reads "X". Agent mode gets it as sent. - The typed box for --environment-alias says "alias", not "ID".
With -o json or --jq, the SDK skips deserialization and returns an unread
body, which vf reads after the call. The SDK's own timeout cancels its
context as the call returns, so that read raced the cancel: on a real
network most runs printed nothing and exited 0, which a script takes for
success.
--timeout now wraps the HTTP client (timeout.go): the deadline runs until
the body is closed, as http.Client.Timeout does. A read that is cut off
(deadline, cancel, network timeout) is an error that explain.go reports as
a timeout; a body the SDK already read is still "no raw body".
The timeout explanation also named an empty server URL ("Check the server
URL , which comes from VF_SERVER_URL") when the error carried no URL; it
now names the setting's value.
A union that is optional and nullable is an OptionalNullable[T], a map holding *T, not a struct. buildUnionField looked its variants up on the map type, so documented flags such as `message add-variant/update-variant --condition.script.code` and `api-tool create/update --body-param.raw-input.content` crashed vf with a Go stack trace (exit 2). The variants are now looked up on T, and the built *T goes back into the map as its set value (unionnullable.go, two one-line hooks in metadata.go). The union's own JSON flag already worked and is unchanged. A new test sends every dotted variant flag in the command tree through --dry-run; with the fix taken out it reports 16 panics.
`vf secret set-value` without --value asked for the secret in a plain text field, so it showed on screen and stayed in the terminal's scrollback. A form field that holds a secret now echoes dots (secretinput.go): the secret commands' generic --value and --default-value, known by their description, and any flag whose name ends in secret, password, token, api key or private key, the rule client/redact.go uses for request bodies.
A body command read any non-terminal stdin as its body, so a command run from a script took the script's input: `bash < script.sh` lost every line after vf, and `while read -r n; do vf …; done < names.txt` stopped after one pass, both failing as "failed to parse stdin as JSON". When the flags already hold the body and stdin is a file whose contents aren't JSON, vf now seeks the file back and goes on with the flags. Piped JSON still merges with the flags, as the README documents, and a pipe is read as before. `--body -` reads the body from stdin on purpose.
`vf document create-text --file faq.md` sent the file as application/octet-stream, because Go's mime table has no .md and macOS lists it nowhere, and the API refused it as "invalid document type". .md and .markdown now go up as text/markdown on every machine; checked against the API, that stores a Markdown document (type "md"). When the API does refuse a file's type, the error now names the file and the types the knowledge base takes, instead of the generic --dry-run and --help hints.
Ctrl-C while a request ran in the home prompt read as a network failure: "Couldn't get project · couldn't reach Voiceflow ⎿ context canceled. Check your internet connection". A canceled request now reads "✗ Canceled", as a form or picker closed with Ctrl-C already does. A request cut off by --timeout is still explained as timing out.
Bubble Tea's init asks the terminal for its background colour (OSC 11 plus a cursor-position query) and waits up to 5s for the answer. It ran before main on every command, so under a terminal that doesn't answer (`script`, `docker run -t`, some CI ptys, emacs shells) even `vf version` and `-o json` took 5s, and a late answer could leak into the shell as `]11;rgb:…`. termbg/hold, which Go initializes before Bubble Tea, sets TERM=dumb so termenv skips the query; termbg's init, after Bubble Tea's, restores TERM and termenv's colour profile. termbg.Detect asks the real question once, just before a form, the home prompt or the explorer takes the terminal, the only places that draw adaptive colours. A test checks the init order and that TERM comes back unchanged. Under `script`: 5.02s → 0.01s for `vf version`, with the same colours.
A path parameter went into the URL as it was, so `vf playbook get --playbook-id "a/b?x=1#frag"` asked for /v2/stable/playbook/a/b?x=1#frag: the "/" reached another endpoint, and the "?" and "#" replaced the real query, dropping projectID and environmentAlias. Each value is now escaped as one path segment, as serialized parameters already were.
vf read any non-terminal stdin as a body to merge under the flags, so:
- `sleep 15 | vf … --name x` waited 10s for a body that never came
- `cmd | while read -r n; do vf … --name "$n"; done` ran once: the
first vf swallowed the loop's remaining lines
- `bash < script.sh` lost the lines after the first vf call
Now stdin is read only when no body flag is given, or when asked for
with `--body -`. Piped JSON with no flags is still the body, unchanged.
When body flags are given and stdin is a file holding a JSON body, vf
leaves it unread and prints a note saying to add `--body -`.
Every --body flag's help now says how stdin is read.
BREAKING CHANGE: piped JSON is no longer merged with body flags on its
own. `echo '{…}' | vf <cmd> --name x` used to merge the two; add
`--body -` to keep that: `echo '{…}' | vf <cmd> --body - --name x`.
Flags still win over the piped body.
Body flags turn off reading stdin, so `echo '{"name":…,"color":…}' |
vf variable create -n x` failed with "needs --color-param" and no word
that the piped body was skipped. A missing body flag now says that body
flags were given, so stdin wasn't read, and to add `--body -` to read
it. It says so only for a pipe or a redirected file, never for a
terminal, /dev/null or an agent's socket, and only on the error, so a
`while read` loop that succeeds stays quiet.
`--body -` with an empty stdin said "needs --name"; it now says stdin
was empty and shows how to pipe the body in.
A body the SDK couldn't serialize failed with the head of Go's marshal chain, cut at 200 characters, so the cause never showed: Couldn't create turn: error serializing request body: json: error calling MarshalJSON for type *components.StableTestTurnCreateRequest: json: error calling MarshalJSON for type …StableTestTurnCreateRequestUser:… Testers read the SDK's source to learn that `variableStates` was missing. The chain's types name the path to the field, so vf now says "the body has no value for user.payload.variableStates", or "the body is none of its forms" when no variant was given, and gives the SDK's cause in full. Any other serialization failure shows its cause rather than the chain's head.
`secret create --name KEY --default-value hunter2` typed in the home prompt came back whole on ↑, the value in clear on screen and in the terminal's scrollback, though the form that asks for the same value hides it. Lines about secrets were already kept off disk; the line kept for ↑ now also loses each flag that holds a secret (as the form knows them: --value and --default-value on secret commands, --token, --password, --api-key and the like) with its value, and on such a command the whole-body --body. Run again, it asks for the value in the hidden form instead of sending a stand-in.
--debug prints `Set-Cookie: [REDACTED]`, but --include-headers printed the header as the server sent it, session cookie and all, into CI logs that are often public. --include-headers now redacts the headers --debug redacts (Set-Cookie, Cookie, Authorization, X-Session-Token, *-token, *-secret …), in JSON, YAML and pretty output alike. A test keeps the two lists the same.
CI's gofmt (Go 1.25, from go.mod) indents a return of multi-line slice literals one level deeper than Go 1.27's does, so two explanations passed locally and failed CI's formatting check. Each now builds its slices first and returns the names, which both versions format alike.
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved session-scope and stdin-handling bugs can target the wrong project or environment, clear selections during dry runs, and swallow subsequent prompt input.
10 open issues
Make the workspace and project picker interruptible · New Initialize agent mode before rendering flag-parsing errors · New Recognize the body field when checking for supplied input · New Prevent terminal stdin reads from outliving the home-prompt command · New Do not clear the current selection on a delete dry run · New Update current project after machine-output project creation · New Use the resolved project when remembering a cloned environment · New Clear the current environment only when both project and alias match · New Carry project and environment scope into variable suggestions · New Preserve literal hashes at the end of headings · New
6 files not reviewed
internal/cli/auth.go: Generated fileinternal/cli/configure.go: Generated fileinternal/cli/root.go: Generated fileinternal/client/client.go: Generated fileinternal/explorer/explorer.go: Generated fileinternal/flagutil/metadata.go: Generated file
What changed in this PR
Building on #55’s terminal UI, this PR adds actionable error messages and context-aware workflows to the Voiceflow CLI, alongside usability and credential-handling fixes.
Changes:
- Adds clearer errors, ID pickers, current-project context, next-command suggestions, and document rendering.
- Changes body flags to leave stdin unread unless
--body -is supplied, with updated help and regression tests. - Fixes response timeouts, optional unions, Markdown uploads, path escaping, terminal startup delays, and credential exposure.
| File | Description |
|---|---|
test/stdin-handling.test.ts |
Tests explicit stdin merging and loop preservation. |
test/errors-teach.test.ts |
Tests actionable errors and local validation. |
test/dry-run.test.ts |
Updates expected error messages. |
test/agent-mode-flag.test.ts |
Updates authentication-error expectations. |
README.md |
Documents personal keys and new stdin behavior. |
npm/cli/README.md |
Documents browser sign-in and personal keys. |
internal/ui/ui.go |
Adds a document bullet glyph. |
internal/ui/markdown.go |
Adds terminal Markdown rendering. |
internal/ui/markdown_test.go |
Tests Markdown styling and wrapping. |
internal/ui/DESIGN.md |
Specifies errors, pickers, context, and documents. |
internal/termbg/termbg.go |
Defers terminal background detection. |
internal/termbg/hold/hold.go |
Suppresses startup terminal queries. |
internal/session/session.go |
Tracks the home prompt’s current scope. |
internal/session/session_test.go |
Tests scope lifecycle and clearing. |
internal/sdk/sdkinternal/utils/pathparams.go |
Escapes simple path parameter values. |
internal/sdk/sdkinternal/utils/pathescape.go |
Adds path-segment escaping. |
internal/sdk/sdkinternal/utils/pathescape_test.go |
Tests escaped URL construction. |
internal/sdk/sdkinternal/hooks/teach.go |
Refocuses hooks on credential preflight checks. |
internal/sdk/sdkinternal/hooks/registration.go |
Removes response-error enrichment registration. |
internal/prompt/prompt.go |
Displays context and defers optional flag menus. |
internal/prompt/prompt_test.go |
Tests context borders and flag-menu behavior. |
internal/prompt/complete.go |
Describes automatically filled flags. |
internal/prompt/complete_test.go |
Tests filled-flag ordering and descriptions. |
internal/output/validate.go |
Validates output options before requests. |
internal/output/validate_test.go |
Tests output-format and jq validation. |
internal/output/reported.go |
Updates single-report error handling. |
internal/output/reported_test.go |
Tests revised single-report messages. |
internal/output/rawbody.go |
Reports interrupted raw-response reads. |
internal/output/rawbody_test.go |
Tests raw-body reads and cancellation errors. |
internal/output/output.go |
Integrates explanations, documents, and redaction. |
internal/output/headerredact.go |
Redacts sensitive response headers. |
internal/output/headerredact_test.go |
Tests header redaction without mutation. |
internal/output/framework.go |
Explains incompatible project frameworks. |
internal/output/framework_test.go |
Tests framework-specific guidance. |
internal/output/document.go |
Presents instruction pages as documents. |
internal/output/document_test.go |
Tests document output and pagination hints. |
internal/output/doctype.go |
Explains unsupported upload types. |
internal/output/doctype_test.go |
Tests file-type guidance. |
internal/output/created.go |
Announces creations and updates current scope. |
internal/output/created_test.go |
Tests creation context and next steps. |
internal/output/canceled.go |
Distinguishes cancellation from network failures. |
internal/output/canceled_test.go |
Tests cancellation and timeout distinctions. |
internal/output/badbody.go |
Explains request serialization failures. |
internal/output/badbody_test.go |
Tests missing-body-field explanations. |
internal/oauth/oauth.go |
Adds identifiable session-renewal errors. |
internal/interactive/secretinput.go |
Identifies fields containing secrets. |
internal/interactive/secretinput_test.go |
Tests secret detection and masked input. |
internal/interactive/picks.go |
Persists previous picker selections. |
internal/interactive/interactive.go |
Integrates pickers and masks secret fields. |
internal/flagutil/unionnullable.go |
Supports optional nullable union variants. |
internal/flagutil/stdinflags_test.go |
Tests body flags and unread-stdin hints. |
internal/flagutil/stdin.go |
Implements explicit stdin reading and diagnostics. |
internal/flagutil/metadata.go |
Integrates stdin rules and nullable unions. |
internal/explorer/explorer.go |
Detects background before opening the explorer. |
internal/client/uploadtypes.go |
Registers Markdown upload MIME types. |
internal/client/uploadtypes_test.go |
Tests Markdown MIME registration. |
internal/client/timeout.go |
Extends request deadlines through body reading. |
internal/client/timeout_test.go |
Tests response-body timeout behavior. |
internal/client/spinner.go |
Supports request-specific spinner messages. |
internal/client/spinner_test.go |
Tests spinner message overrides. |
internal/client/headerredact_test.go |
Checks consistency between redaction paths. |
internal/client/client.go |
Integrates the timeout wrapper. |
internal/cli/uploadtypes_test.go |
Tests Markdown uploads through the CLI. |
internal/cli/unionflags_test.go |
Tests union flags across commands. |
internal/cli/termquery_test.go |
Tests initialization order and TERM restoration. |
internal/cli/stdinhint_test.go |
Tests stdin-related CLI guidance. |
internal/cli/root.go |
Integrates body help and usage-error rendering. |
internal/cli/pickers.go |
Provides API-backed scope choices. |
internal/cli/pickers_test.go |
Tests picker data against a mock API. |
internal/cli/pathescape_test.go |
Tests escaped IDs through a command. |
internal/cli/home.go |
Adds current scope, use, and contextual suggestions. |
internal/cli/home_test.go |
Tests context-aware home suggestions. |
internal/cli/historysecret.go |
Removes secret-bearing flags from history. |
internal/cli/historysecret_test.go |
Tests history sanitization and quoting. |
internal/cli/errors_test.go |
Tests usage explanations and access guidance. |
internal/cli/configure.go |
Improves authentication guidance and form startup. |
internal/cli/bodyhelp.go |
Standardizes stdin help for body flags. |
internal/cli/bodyhelp_test.go |
Checks body help across commands. |
internal/cli/auth.go |
Updates personal-key guidance and form startup. |
Review effort: Balanced
| fmt.Fprintln(os.Stderr, u.Status(ui.StatusDone, "Nothing is current now: commands ask again")) | ||
| case len(args) == 1 && useLevels[args[0]] != "": | ||
| output.ResetAgentMode() | ||
| it, err := interactive.PickCurrent(cmd, useLevels[args[0]]) |
| if cmd, err := unknownSubcommand(rootCmd, commandLine()); err != nil { // errors.go: 'vf workspace lsit' fails rather than printing help | ||
| return renderError(cmd, err) | ||
| } | ||
| return renderError(rootCmd.ExecuteC()) // errors.go: what went wrong, why, and what to do next |
| // given. Path and query parameters aren't part of the body. | ||
| func bodyFlagsGiven(cmd *cobra.Command, meta []FlagMeta, bodyFieldPath string) bool { | ||
| for _, m := range meta { | ||
| if bodyFieldPath != "" && !strings.HasPrefix(m.FieldPath, bodyFieldPath+".") { |
| if strings.TrimSpace(v) != "-" { | ||
| return v, nil | ||
| } | ||
| data, err := readStdinBounded(cmd.InOrStdin(), 0) |
Comment on lines
+49
to
+51
| case "delete": | ||
| forgetDeleted(cmd) | ||
| return noop |
Comment on lines
+57
to
+60
| obj := createdObject(extractResultContent(res)) | ||
| id := firstString(obj, "id", "alias") | ||
| if id == "" { | ||
| return noop // a dry run, or a response vf can't read a thing from |
| case "project": | ||
| session.Set("workspace-id", firstString(obj, "workspaceID"), "") | ||
| } | ||
| session.Set(flag, id, name) |
Comment on lines
+141
to
+143
| if cur, ok := session.Get(flag); ok && cur.Value == f.Value.String() && contextFlags[cmd.Parent().Name()] == flag { | ||
| session.Clear(flag) | ||
| } |
Comment on lines
+193
to
+195
| tips = append(tips, ui.Tip{Command: sibling.CommandPath() + " --" + idFlag + " " + id, Does: "see it"}) | ||
| case sibling.Name() == "list": | ||
| tips = append(tips, ui.Tip{Command: sibling.CommandPath(), Does: "list them"}) |
| } | ||
|
|
||
| var ( | ||
| mdHeading = regexp.MustCompile(`^(#{1,6})\s+(.*?)\s*#*\s*$`) |
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
Stacked on #55. The base is
braden/terminal-ui-and-fixes/COR-0, so this diff shows only these 29 commits. Retarget tomasteronce #55 merges.Four pieces of work. Each commit builds and passes CI on its own, so the PR reads best commit by commit.
A command given any body flag no longer reads stdin. Piped JSON with no body flags is still the body, as before.
Why: reading stdin whenever it wasn't a terminal caused three problems.
sleep 15 | vf … --name xwaited 10s for a body that never came.cmd | while read -r n; do vf … --name "$n"; doneran once, because the first vf swallowed the loop's remaining lines.bash < script.shlost every line after the first vf call.ghhandles this the same way: it reads stdin only for--input -.What else changed with it:
--bodyhelp text now says how stdin is read.vf … --name x < body.jsonprints a note saying to add--body -.Commits, in review order
1. Errors that teach
feat(client): let a request say what the spinner is waiting forfeat(interactive): pick a missing ID from a listfeat: list organizations, workspaces, projects and environmentsfeat(output): explain every API and connection error, with next stepsfix(output): check --output-format and --jq before sending the requestfeat(cli): explain usage errors with a cause and next stepsdocs: specify how errors read, and call personal keys by their namefeat(output): name the organization or workspace a refusal targetedfeat(home): carry the current workspace and project to the next commandfeat(home): suggest the next command for what is currentfeat(home): make creating a project the default first stepfeat(home): lead with creating a project, in the banner and the promptfix(interactive): offer optional fields only on commands that make or change somethingfeat(home): take the main environment, and let flags wait until askedfeat(output): show a prompt's page as a documentfix(interactive): name what was picked, and explain older projects2. Usability-sweep fixes
fix(client): --timeout no longer prints nothing and exits 0-o json/--jq, a timeout sometimes printed nothing and exited 0fix(flagutil): variant flags on optional unions no longer panicfix(interactive): type a secret's value unseensecret set-valueshowed the secret as it was typedfix(flagutil): give a script's own input back, and read --body ---body -fix(document): upload a .md file as Markdown.mduploaded asapplication/octet-stream, and the API rejected itfix(output): Ctrl-C during a request says Canceledfix(ui): stop the 5s terminal query on every commandvf version, hung 5s in a terminal that doesn't answer terminal queries. Startup is now 0.01s with the same coloursfix(sdk): escape an ID that goes in the URL path/,?or#could leave its path segment3. Breaking change
fix(flagutil)!: body flags turn off reading stdin4. Follow-ups from the re-run
fix(flagutil): say when body flags left a piped body unreadwhile readloop that succeeds stays quiet.--body -on an empty stdin says sofix(output): name the field a request body is missingfix(home): keep a secret's value out of the prompt's history--value/--default-valuein clearfix(output): redact credentials in --include-headersSet-Cookieunredacted. It now redacts what--debugredactsTesting
go build, gofmt,scripts/vet.sh,go test ./...yarn oxlintgo.mod/go.sumNot in this PR
Bigger issues the sweep found that are still open:
environment compileis run.conversation sendhas no plain way to send a message.test run waitexits 0 when runs failed.-o tablefails, and-o yamlchanges key names.