Skip to content

refactor(cli): list avatar looks through the generated client - #9224

Queued
jrusso1020 wants to merge 1 commit into
mainfrom
cli-avatar-looks-generated-call
Queued

jrusso1020 wants to merge 1 commit into
mainfrom
cli-avatar-looks-generated-call

Conversation

@jrusso1020

Copy link
Copy Markdown
Collaborator

What

hyperframes media-use lists a signed-in user's avatar looks through the generated HeyGen client, in place of a hand-built URL and fetch. The request sent and the looks returned are unchanged.

Why

The generated client now has this call. Using it means the path and query names come from the API description, so a change there fails the build, not a run.

Related work

Follows #9150 (typed request bodies) and #9153 (the client resync that added the call).

How

Claude Fable 5.2

Changes

  • packages/cli/src/heygen/avatars.ts only (+30 -26). fetchPage calls client.listAvatarLooks({ ownership: "private", limit, token }) with the same 30 second timeout.
  • The client is built once per listing with the same base URL, the same sign-in headers plus accept: application/json, and fetchExplained as its fetch, so a network failure still arrives as the same explained error.
  • Refusals keep their text and fix: a 401 or 403 says to sign in again, any other status says to run the command again, and an answer that is not a list says so.

Self-review

Read against the generated client's request code. Same as before: path, query names and order, headers, the timeout, paging by next_token, and the handling of an empty or non-JSON answer with a 2xx status (still "answered its avatars with no list").

Two differences, both outside normal use:

  • The URL is the base URL followed by the path. Before, the path replaced any path on the base URL. They differ only for a base URL that carries its own path.
  • If the 30 second timeout fires after the status line and during the body, the message is now "no answer from HeyGen for its avatars" where it was "answered its avatars with no list". The fix line is the same.

Test plan

  • vitest run src/heygen src/commands/media-use in packages/cli: 10 files, 214 tests pass, no test edited. The existing tests for this file pin the path, ownership, limit, the key header, paging to the limit, the sign-in refusal and the network failure text.

  • tsc --noEmit for packages/cli: clean.

  • oxlint, oxfmt --check and the comment check: clean.

  • Not run against the live API.

  • Unit tests added/updated (no behaviour change; existing tests cover it)

  • Manual testing performed

  • Documentation updated (if applicable)

  • Comments follow CONTRIBUTING.md "Comments": they say why, not what, and a bug fix says what the code must do and how to reproduce the bug

Authored by Rames (api-platform).

🤖 Generated with Claude Code

The look list was the one HeyGen request the media-use client still
wrote by hand. It now goes through the generated call. The request sent,
the refusals and the paging are unchanged.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

@miguel-heygen miguel-heygen 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 06fab81d387d. Clean migration of ownAvatarLooks to HyperframesCloudClient.listAvatarLooks:

  • Preserves the /v3/avatars/looks path, ownership: "private", limit, token paging, 30s timeout, auth + accept: application/json headers, and fetchExplained network-error wrapping.
  • Handles non-JSON / empty 2xx responses (HyperframesApiError with 2xx status or pageOf(undefined) -> noList()), 401/403 re-auth hints, and other HTTP refusals consistently with the generated client's request() implementation.

Ran vitest run src/heygen src/commands/media-use (10 files, 214/214 passing), and all 69 CI checks including CodeQL are green at head.

@jrusso1020
jrusso1020 added this pull request to the merge queue Dec 1, 2026
Any commits made after this event will not be merged.

This branch has not been deployed

No deployments
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