Skip to content

fix(http): preserve structured transport errors - #28

Merged
JackCaow merged 3 commits into
eric8810:masterfrom
JackCaow:codex/fix-napi-transport-errors
Aug 13, 2026
Merged

fix(http): preserve structured transport errors#28
JackCaow merged 3 commits into
eric8810:masterfrom
JackCaow:codex/fix-napi-transport-errors

Conversation

@JackCaow

Copy link
Copy Markdown
Collaborator

Summary

  • convert native N-API failures into stable CatcherError and HttpError instances instead of GenericFailure
  • classify refused connections and fallback transport failures with explicit codes, phases, retryability, and sanitized details
  • retain the final structured cause inside RETRY_EXHAUSTED
  • add a macOS, Linux, and Windows N-API error-contract CI matrix

Downstream behavior

Moti can now distinguish transport failures from HTTP responses without parsing error text. The downstream compatibility patch retains the existing stateless client rebuild policy, only rebuilds for structured transport causes, and never replays mutation requests.

Validation

  • cargo check for catcher-core, catcher-http, and catcher-napi-http
  • cargo test for catcher-core, catcher-http, and catcher-napi-http
  • cargo clippy for the modified Rust crates with warnings denied
  • pnpm lint
  • N-API native release build and focused error-contract tests: 4 passed
  • downstream Moti recovery, diagnostics, registry, and auth tests: 45 passed

The repository-wide pnpm test run completed 345 tests successfully with 1 skipped. Two network-dependent cases failed in the current environment: real proxy forwarding P8, and a stochastic packet-loss case where both vanilla and N-API requests failed. These are outside the focused error-contract regression suite.

Acceptance boundary

The new CI matrix validates the native contract on hosted macOS, Linux, and Windows runners after this PR is opened. A real Windows EV-signed Moti package remains a separate downstream release acceptance gate.

@JackCaow

Copy link
Copy Markdown
Collaborator Author

Addressed the review findings in b544a0b:

  • Replaced the middleware error chain call with the local error_chain(error.as_ref()) helper. The previous code did compile (the first CI run was green), but the helper removes the concrete error API dependency.
  • Confirmed HttpTransport uses only MetricsRetryMiddleware. retry_with_backoff is an independent public Rust helper and is not in the HttpTransport call path. Added a regression proving an existing RetryExhausted is neither retried nor nested.
  • Removed the platform-dependent reason text assertion; the contract now asserts structured code/phase/retryable fields plus non-empty, sanitized reason data.
  • Documented that attempts is the total number of executions, including the initial request.
  • Kept the prefixed JSON transport. Existing structured invalid-config coverage continues to validate parsing and malformed/non-prefixed values still fall back to the original Error path.

Local validation: cargo check/test/clippy passed for catcher-core, catcher-http, and catcher-napi-http; N-API release build and typecheck passed; focused N-API error-contract tests passed 4/4.

@JackCaow
JackCaow merged commit 6f5883b into eric8810:master Aug 13, 2026
7 checks passed
@github-actions github-actions Bot mentioned this pull request Aug 7, 2026
@github-actions github-actions Bot mentioned this pull request Aug 13, 2026
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