Skip to content

test(cli): cover cloud reportApiError hint cascade#1131

Merged
miguel-heygen merged 1 commit into
heygen-com:mainfrom
calcarazgre646:test/cloud-report-api-error
May 31, 2026
Merged

test(cli): cover cloud reportApiError hint cascade#1131
miguel-heygen merged 1 commit into
heygen-com:mainfrom
calcarazgre646:test/cloud-report-api-error

Conversation

@calcarazgre646
Copy link
Copy Markdown
Contributor

What

Adds packages/cli/src/cloud/errors.test.ts covering reportApiError, the shared error reporter for the cloud render/list/get/delete subverbs.

Why

reportApiError centralizes the HyperframesApiErrorErrorString cascade and applies the curated ERROR_CODE_HINTS table with a specific priority order: code-specific hint > caller suggestion > bare code label > no third line. That priority logic was the only file in cloud/ without test coverage, and the module comment notes a past regression (review finding 10) where hyperframes_render_not_found was unreachable from get/delete. These tests pin the cascade so that class of regression is caught.

Coverage

Ten cases:

  • 404 + notFound option short-circuits to a "Not found" box
  • known error code uses its ERROR_CODE_HINTS entry
  • code-specific hint takes priority over a caller suggestion
  • suggestion fallback when the code has no hint
  • bare code: <code> label when there is no hint and no suggestion
  • no third line when there is no code, hint, or suggestion
  • extraHints merges on top of the built-in table, and overrides a built-in entry
  • plain Error reported with the stage title and suggestion
  • non-Error thrown value stringified

errorBox and process.exit are mocked following the existing sibling pattern in cloud/parsing.test.ts. No source changes. Full cloud/ suite passes (46/46).

reportApiError centralizes the HyperframesApiError -> Error -> String
reporting cascade for the cloud subverbs, including the curated
ERROR_CODE_HINTS table and its priority order (code-specific hint >
caller suggestion > bare code label > no third line). That priority
logic was previously untested; the module comment notes a past
regression where hyperframes_render_not_found was unreachable from
get/delete.

Add errors.test.ts covering: 404 + notFound short-circuit, known-code
hint, hint-wins-over-suggestion priority, suggestion fallback, bare
code label, no-third-line, extraHints merge and override, plain Error,
and non-Error stringification. Mocks errorBox and process.exit
following the sibling cloud/parsing.test.ts pattern.
@miguel-heygen miguel-heygen merged commit f8abff2 into heygen-com:main May 31, 2026
34 checks passed
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