Skip to content

Fix more generated-CLI behavior bugs via patches (stopgap for upstream) - #23

Merged
Kevin-Chant merged 1 commit into
mainfrom
kc/cli-behavior-fixes
Jul 14, 2026
Merged

Kevin-Chant merged 1 commit into
mainfrom
kc/cli-behavior-fixes

Conversation

@Kevin-Chant

@Kevin-Chant Kevin-Chant commented Jul 14, 2026 •

Copy link
Copy Markdown
Member

Features and Changes

A second batch of stopgap fixes for behavior bugs found smoke-testing the CLI, each carried as a .speakeasy/patches/ override that re-applies on every regen (pending upstream Speakeasy/spec fixes). Follows #14.

  • Pagination hint. HasMorePages now reads the response body's own hasMore flag instead of the SDK's Next closure, which is assigned unconditionally and so was always non-nil — the "more pages available" hint printed after every list command, and even after --dry-run. Now it prints only when more pages actually exist.
  • --body - reads stdin. A lone - was parsed as literal JSON (invalid character '-' in numeric literal). It now follows the Unix idiom and reads the body from stdin, in both the whole-body and per-field body paths.
  • Flag metavars. Cobra's UnquoteUsage treats the first back-quoted word in a flag's description as the metavar placeholder, so markdown backticks in spec descriptions produced junk like --prerequisites true, --rules allEnvironments. RegisterFlags now strips backticks before registration → --prerequisites stringArray, --rules string. This also cleans the 50 regenerated doc files.
  • TOON / pretty trailing newline. Both now emit exactly one trailing newline instead of gluing to the next shell line.
  • settings get schema drift. Org settings can hold values that don't match the strict typed schema (e.g. updateSchedule.hours stored as a string). The command now falls back to a lenient generic decode so it succeeds in every output format instead of hard-failing. In agent mode, a response-decode error is classified as response_error with an actionable hint rather than connection_error / "check network connectivity".
  • Doubled binary name. get-SDK-payload and post-copy-transform examples no longer read growthbook growthbook <cmd>.
  • v1 deprecation notice now links the full MIGRATION.md URL.

Generation bumped the version 1.1.1 → 1.1.2.

⚠️ --body - and the metavar change alter user-facing flag behavior/help (and the docs surface), though neither is a breaking change for existing scripts.

Upstream tracking

Each class of bug has a tracking issue so we know what's still waiting on upstream and how to retire the patch (not auto-closed by this PR — the patches are stopgaps): #24 (pagination hint), #25 (--body -), #26 (backtick metavars), #27 (trailing newline), #28 (agent-mode decode classification), #29 (doubled binary name), #30 (--usage KDL — unpatched), #31 (settings.hours — back-end/spec).

Known issues (deferred)

  • --usage KDL still lists table. A patch for this conflicts on every version bump (the table string shares the single 260 KB KDL line with version "1.1.1"), so it's un-shippable as a stable patch. Human-facing --help is already correct; only the machine-readable schema is affected. Best fixed upstream.
  • settings.hours typing — the root fix (type hours to tolerate a string, or coerce in the back-end) belongs in the spec; tracked separately. This PR only makes the CLI degrade gracefully.
  • Revision subcommand renames (raw operationIds → clean verbs) will land in a separate follow-up.

Testing

  • speakeasy run applies all 8 code patches cleanly; staticcheck + go test ./... pass; binary builds (growthbook 1.1.2).
  • go generate ./... — command-surface golden refreshed.
  • echo '{"id":"test"}' | growthbook features create --body - --dry-run → body populated from stdin (no parse error).
  • growthbook features create --help → metavars render as string / stringArray, backticks gone.
  • growthbook --help → output-format no longer lists table.
  • Pretty output ends with exactly one trailing newline (unit test).

Batch of behavior-bug fixes found smoke-testing the CLI, each carried as a
.speakeasy/patches/ override that re-applies on every regen (pending upstream
Speakeasy/spec fixes).

- Pagination hint: HasMorePages now reads the response's own hasMore flag
  instead of the SDK's always-non-nil Next closure, so "more pages available"
  no longer prints after every list command (or after --dry-run).
- --body -: a lone "-" now reads the body from stdin in both body paths
  (previously parsed as literal JSON -> "invalid character in numeric literal").
- Flag metavars: strip markdown backticks from descriptions so Cobra's
  UnquoteUsage stops turning a back-quoted word into the metavar placeholder
  (--prerequisites true -> --prerequisites stringArray). Also cleans the 50
  generated doc files.
- TOON/pretty output: guarantee exactly one trailing newline.
- settings get: fall back to a lenient generic decode when the typed decode
  fails on response schema drift (e.g. updateSchedule.hours stored as a
  string) so the command succeeds in every format instead of hard-failing;
  agent mode now classifies decode errors as response_error (with an
  actionable hint) rather than connection_error.
- get-SDK-payload / post-copy-transform: drop the doubled binary name in
  their examples.
- v1 deprecation notice: link the full MIGRATION.md URL.

Version bumped 1.1.1 -> 1.1.2 by generation.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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