Skip to content

hide and warn on deprecated commands instead of dropping them (PRINFRA-5843) - #554

Merged
somanshreddy merged 1 commit into
mainfrom
11-09-deprecated_commands
Nov 10, 2026
Merged

somanshreddy merged 1 commit into
mainfrom
11-09-deprecated_commands

Conversation

@somanshreddy

@somanshreddy somanshreddy commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator

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 --help says 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 six heygen voice commands.

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/voices endpoints were switched off that way, and the pending resync PR deletes all six heygen voice commands, which are still in wide use, so every script calling them would start failing.

Marking the endpoint deprecated instead gives:

heygen voice list today Endpoint hidden from the CLI Endpoint marked deprecated (this PR)
Listed in heygen --help yes no no
Runs yes no, unknown command, exit 2 yes, same request, same JSON on stdout
stderr nothing usage error {"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

  • Codegen copies the OpenAPI operation's standard deprecated field into a new Spec.Deprecated, and the template emits it.
  • Spec.IsHidden now 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.
  • The builder prefixes the command's long description with the notice and calls warnDeprecatedCommand next to the existing warnDeprecatedFlags, after the --request-schema short-circuit, so the warning goes through formatter.Warn (stderr, same envelope as the deprecated-flag warning).
  • deprecatedCommandReplacements in cmd/heygen/ maps an operation's METHOD /path to 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 deprecated flag 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

  • No effect until an operation in the spec carries deprecated: true; none does today.
  • For the voice commands, EF needs a follow-up that replaces cli_visible=False with deprecated=True on the six /v3/voices operations. 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.
  • MCP generation and the API reference docs do not read operation-level 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

  • Codegen: an operation marked deprecated sets Spec.Deprecated and its sibling does not; the golden output carries Deprecated: true.
  • Runtime: a deprecated command still sends its request, exits 0, keeps stdout parseable JSON, and writes exactly one warning envelope naming the replacement; a non-deprecated sibling writes nothing to stderr. Root help omits an all-deprecated group, and the command's own --help leads with the notice.
  • Every replacement in deprecatedCommandReplacements resolves to a real, runnable command.
  • Each new test was confirmed to fail when the line it covers is removed.
  • End to end: regenerated from today's prod spec with the six /v3/voices operations marked deprecated, built the binary, and ran heygen voice list --limit 1 against the live API: exit 0, JSON on stdout, the warning on stderr (and as Warning: under --human); voice no longer appears in heygen --help, model still does.
  • make lint, make test.

🤖 Generated with Claude Code

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 jrusso1020 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 --json flag (that is a usage error).
  • Replacements are not supplied by the spec: the spec supplies deprecated, while deprecatedCommandReplacements supplies the successor by METHOD /path. TestDeprecatedCommandReplacementsExist checks 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 282773de sync-cli-codegen.yml runs make generate from the CLI checkout and commits only gen/; 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 at 451b52e6; 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.

@somanshreddy somanshreddy changed the title hide and warn on deprecated commands instead of dropping them hide and warn on deprecated commands instead of dropping them (PRINFRA-5843) Nov 10, 2026
@somanshreddy
somanshreddy merged commit e3f32c3 into main Nov 10, 2026
10 checks passed
@somanshreddy
somanshreddy deleted the 11-09-deprecated_commands branch November 10, 2026 01:44
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.

2 participants