Skip to content

feat(ts): ts_error_handling=result — typed Result return for es-mode client - #241

Merged
SebastienMelki merged 1 commit into
mainfrom
feat/ts-es-result-errors-v2
Aug 6, 2026
Merged

feat(ts): ts_error_handling=result — typed Result return for es-mode client#241
SebastienMelki merged 1 commit into
mainfrom
feat/ts-es-result-errors-v2

Conversation

@SebastienMelki

Copy link
Copy Markdown
Owner

Summary

This is @hishamank's work from #210, rebased cleanly onto main after #207 was squash-merged (which deleted the base branch and auto-closed #210).

All code authored by @hishamank — original PR: #210. Previously approved by @SebastienMelki.

Changes

  • Adds ts_error_handling=result plugin option (requires ts_runtime=protobuf-es)
  • Unary methods return Promise<Result<T, ClientError>> instead of throwing
  • ClientError = discriminated union of ValidationError | ApiError | <every proto *Error type>
  • Structural error registry matches response JSON keys against proto Error schemas
  • Zero-field *Error guard: keys.length > 0 prevents empty errors from matching everything
  • SSE methods still throw (can't return Result from AsyncGenerator)
  • 3 lint findings cleared (funlen, goconst, perfsprint)

Test plan

  • CI passes (first-ever CI run for this code)
  • Golden files match expected output
  • go test ./internal/tsclientgen/... ./internal/tscommon/... ./internal/urlparamtest/... all pass

🤖 Generated with Claude Code

…client

Adds ts_error_handling=result plugin option (requires ts_runtime=protobuf-es).
Unary methods return Promise<Result<T, ClientError>> instead of throwing.
ClientError is a discriminated union of ValidationError | ApiError | every
proto *Error type. Structural error registry matches response JSON keys
against proto Error schemas. Zero-field *Error guard prevents empty errors
from shadowing.

Original work from PR #210.

Co-Authored-By: Hicham <53556927+hishamank@users.noreply.github.com>
@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown

🔍 CI Pipeline Status

Lint: success
Test: success
Coverage: success
Build: success
Integration: success


📊 Coverage Report: Available in checks above
🔗 Artifacts: Test results and coverage reports uploaded

@codecov

codecov Bot commented Aug 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 18.18182% with 135 lines in your changes missing coverage. Please review.
✅ Project coverage is 28.64%. Comparing base (c432ae9) to head (b48eaf2).

Files with missing lines Patch % Lines
internal/tscommon/result.go 0.00% 109 Missing ⚠️
internal/tsclientgen/generator.go 36.00% 14 Missing and 2 partials ⚠️
internal/tscommon/imports.go 0.00% 8 Missing ⚠️
internal/tsclientgen/modules.go 71.42% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #241      +/-   ##
==========================================
- Coverage   28.80%   28.64%   -0.16%     
==========================================
  Files          73       74       +1     
  Lines       12890    13048     +158     
==========================================
+ Hits         3713     3738      +25     
- Misses       8989     9119     +130     
- Partials      188      191       +3     
Flag Coverage Δ
unittests 28.64% <18.18%> (-0.16%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@SebastienMelki
SebastienMelki merged commit 6ba2ebf into main Aug 6, 2026
10 checks passed
@SebastienMelki
SebastienMelki deleted the feat/ts-es-result-errors-v2 branch August 6, 2026 09:03
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