Skip to content

fix(cli): name the network cause of a failed fetch in the error box - #7236

Merged
miguel-heygen merged 1 commit into
mainfrom
dcloudpro/cli-error-code
Nov 5, 2026
Merged

miguel-heygen merged 1 commit into
mainfrom
dcloudpro/cli-error-code

Conversation

@miguel-heygen

Copy link
Copy Markdown
Collaborator

Problem

A cloud command whose network call fails prints only fetch failed: the error's cause.code (ETIMEDOUT, ECONNRESET, ENOTFOUND, a TLS code) is dropped, so neither the person nor a host app can tell a timeout from a DNS failure or a bad certificate.

Change

reportApiError adds a third line code: <CODE> to the box for a generic error whose cause carries an upper-case error code. The message line stays fetch failed, so anything matching that line keeps working. A cause code that is not shaped like an error code (free text, a path) is ignored; a caller's own suggestion still wins.

Verified

errors.test.ts: 14 pass; the new test fails on main (the box gets no third line). Formatted with oxfmt; the repo lint hook was not run (no local install).

fails without the fix: names the network cause of a failed fetch on the third line, and nothing for a free-text cause

@heygengenesis heygengenesis Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approving at 081637f0.

Checked:

  • Fails without the fix: I put errors.ts back to the main version (b7a8cfa7) and the named test fails: names the network cause of a failed fetch on the third line, and nothing for a free-text cause is missing the expected "code: ETIMEDOUT" third line. With the fix, all 14 tests in errors.test.ts pass.
  • Message line unchanged: the second argument to errorBox is still err.message (fetch failed). recordFailure(title, hint ?? suggestion) records that same message, so anything matching on it sees no change. The cause shows up only in the suggestion slot, and only when the caller passed no suggestion.
  • Scope: only the generic Error branch changes. HyperframesApiError and non-Error values behave as before. The ^[A-Z][A-Z0-9_]{2,40}$ check keeps free-text or path-like cause.code values out of the output.
  • Types: tsc shows no errors in cloud/errors.ts. CI passed on this head.

Nit (not blocking): networkCode and its one-line doc sit between reportApiError's long JSDoc block and the function itself. That JSDoc now attaches to networkCode, so reportApiError loses its hover docs. Moving networkCode above that block would fix it.

@miguel-heygen
miguel-heygen added this pull request to the merge queue Nov 5, 2026
Merged via the queue into main with commit f55990e Nov 5, 2026
69 checks passed
@miguel-heygen
miguel-heygen deleted the dcloudpro/cli-error-code branch November 5, 2026 13:38
SanHsien added a commit to SanHsien/hyperframes that referenced this pull request Nov 6, 2026
…eview

Adopts or partially adopts 11 groups: multi-worker tween replay behind
the timeline stand-in (heygen-com#7231), template entries in the shared compile
stage (heygen-com#7217), HYPERFRAMES_CACHE_DIR and HYPERFRAMES_CONFIG_DIR for
every per-user cache and settings file (heygen-com#7224, heygen-com#7229; HeyGen
credentials stay under HEYGEN_CONFIG_DIR), WebKit audio clock (heygen-com#7225),
packet-based video length (heygen-com#7233), HLG tone mapping (heygen-com#7234), fetch
network cause (heygen-com#7236), .hyperframesignore in lint (heygen-com#7239), info
--media (heygen-com#7235), lint priority (heygen-com#7244), check --budget (heygen-com#7245) and the
unknown-command answer (heygen-com#7247). bun.lock gains only the lint `ignore`
edge from heygen-com#7239, already resolved. Watermark advances to 0a6746e.

Co-authored-by: Jerrai <[email protected]>
Co-authored-by: Miguel Ángel <[email protected]>
Co-authored-by: WaterrrForever <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
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