Repository navigation
hide and warn on deprecated commands instead of dropping them (PRINFRA-5843) - #554
Conversation
An operation marked deprecated in the OpenAPI spec now generates a command that still runs but is hidden from help, leads its own --help with a deprecation notice, and prints a warning on stderr pointing to its replacement. Co-Authored-By: Claude Opus 5.5 <[email protected]>
jrusso1020
left a comment
There was a problem hiding this comment.
Reviewed at 5ae26fa65b2d378f63e1369d74b584096d0b0b5e.
The codegen-to-runtime contract preserves commands and reuses the existing hidden-command and formatter paths (codegen/grouper.go:436, codegen/templates/command.go.tmpl:29, cmd/heygen/builder.go:83). No blocker found.
- Hiding an all-deprecated group is consistent with the declared intent. It removes discovery, not registration: explicit nested invocation and leaf help remain available.
- Warnings use the JSON/human formatter's stderr writer, including when an API error follows. Schema introspection returns before the warning. Argument, flag, raw-JSON parsing and authentication failures before RunE can return an error without a deprecation warning; none redirects it to stdout. This CLI has default JSON/agent output,
HEYGEN_OUTPUT=json|human, and--human; it has no supported--jsonflag (that is a usage error). - Replacements are not supplied by the spec: the spec supplies
deprecated, whiledeprecatedCommandReplacementssupplies the successor byMETHOD /path.TestDeprecatedCommandReplacementsExistchecks that all six targets resolve to runnable commands. Unmapped operations receive the generic warning.gen/at this head has no deprecated command markers, so the new behavior awaits spec regeneration. - Sync audit: EF master
282773desync-cli-codegen.ymlrunsmake generatefrom the CLI checkout and commits onlygen/; it preserves the authored map/template. Existing sync branches are reused, however, so any older sync branch needs a base containing this generator before regenerating. The original deletion PR #550 is now CLOSED at451b52e6; this PR does not repair its old generated deletion by itself.
Nit — description accuracy: the public CLI command reference does change once deprecated operations arrive. EF .github/scripts/cli_docs_dump/main.go:67 filters Spec.IsHidden(), and the sync workflow uses that dumper to regenerate heygen-api/commands.mdx. Please qualify “public docs ... unaffected” to distinguish API docs from this CLI reference. This omission from the reference matches the intended hidden-command policy.
Validation: /home/ubuntu/workspaces/pytest-gate.sh go test -p 2 ./... passed all 11 test-bearing packages, including the codegen golden test and reviewer probes (12 output/error-mode cases, both schema paths, usage errors, and nested all-deprecated-group execution). A focused rerun also passed after restoring source. Removing the builder warning made TestDeprecatedCommandRunsAndWarnsOnStderr fail with stderr = ""; restoration passes. Mock API only; no live credential or production request used.
Need: yes, preserve scripts during deprecation · Size: ok · Reuse: IsHidden, hideEmptyGroups, formatter.Warn · Simpler: already minimal · Structure: fine (checked deprecated flags, aliases and generated/runtime Spec contract; no split)
Risk: low — limited to operations marked deprecated; request execution unchanged.
— Rames / pr-review
Verdict: APPROVE
Reasoning: Deprecated commands remain executable and warnings stay off response stdout. The CLI-reference description clarification is non-blocking.
Scope
Surfaces: CLI | Module: Codegen / command builder
Summary
When the API marks an endpoint deprecated, the CLI now keeps its command working instead of dropping it: the command is hidden from help, its own
--helpsays it is deprecated, and running it prints a warning on stderr that names the replacement. This changes nothing on merge, because no endpoint in the current spec is marked deprecated. It gives the API side a non-breaking way to retire a command, starting with the sixheygen voicecommands.How it works
Today the API has one switch for the CLI: hide the endpoint from the CLI, which stops the command from being generated at all. The
/v3/voicesendpoints were switched off that way, and the pending resync PR deletes all sixheygen voicecommands, which are still in wide use, so every script calling them would start failing.Marking the endpoint deprecated instead gives:
heygen voice listtodayheygen --helpunknown command, exit 2{"warning":{"message":"\"heygen voice list\" is deprecated and will be removed in a future version; use \"heygen model audio voices list\" instead"}}A group whose commands are all deprecated (here,
voice) is hidden too. The commands can then be removed in a later major version, once their usage has dropped.Technical details
Implementation
deprecatedfield into a newSpec.Deprecated, and the template emits it.Spec.IsHiddennow also returns true for a deprecated spec, so the existing hidden-command path handles help listings, and the existing empty-group pass hides a group whose children are all hidden.warnDeprecatedCommandnext to the existingwarnDeprecatedFlags, after the--request-schemashort-circuit, so the warning goes throughformatter.Warn(stderr, same envelope as the deprecated-flag warning).deprecatedCommandReplacementsincmd/heygen/maps an operation'sMETHOD /pathto its successor command. The spec has no field for a successor, so this is CLI-side lookup data, like the curated columns.Design decisions
Spec-driven, not a hand-kept list. The operation's own
deprecatedflag is what the API team already sets, and the existing deprecated-flag support works the same way.Warning on stderr through the formatter, not Cobra's
Deprecated. Same reason as for deprecated flags (see CONTRIBUTING): stdout must stay parseable JSON.Rollout and risk
deprecated: true; none does today.cli_visible=Falsewithdeprecated=Trueon the six/v3/voicesoperations. The resync after that deploy keeps the commands as deprecated instead of deleting them. The current resync PR (codegen: resync gen/ from EF 5d4cf6f5 #550) should not merge before then.deprecated, so they are unaffected. The generated CLI command reference does change: it lists only commands that are not hidden, so deprecated commands drop out of it, matching--help.Testing
Spec.Deprecatedand its sibling does not; the golden output carriesDeprecated: true.--helpleads with the notice.deprecatedCommandReplacementsresolves to a real, runnable command./v3/voicesoperations marked deprecated, built the binary, and ranheygen voice list --limit 1against the live API: exit 0, JSON on stdout, the warning on stderr (and asWarning:under--human);voiceno longer appears inheygen --help,modelstill does.make lint,make test.🤖 Generated with Claude Code