feat: introduce unified SDKError type and ObservabilityError extension#1286
Merged
serikjensen merged 6 commits intomainfrom Mar 19, 2026
Merged
feat: introduce unified SDKError type and ObservabilityError extension#1286serikjensen merged 6 commits intomainfrom
serikjensen merged 6 commits intomainfrom
Conversation
krisxcrash
approved these changes
Mar 18, 2026
jeffredodd
approved these changes
Mar 19, 2026
Contributor
jeffredodd
left a comment
There was a problem hiding this comment.
LGTM, thanks for the improvement.
Adds a universal SDKError type that normalizes all error scenarios (API, validation, network, internal) into a single structured shape with category, message, httpStatus, fieldErrors, and raw error. This replaces the fragmented error handling and prepares for the upcoming hooks-based architecture where partners interact with errors directly. ObservabilityError extends SDKError with timestamp, componentName, and componentStack for telemetry — keeping the partner-facing type clean. - normalizeToSDKError is a pure function of error type (no options) - Base infrastructure updated to use SDKError for component state - Observability layer enriches with context at emission sites - Removed deprecated types and createObservabilityError - Updated integration guide documentation Made-with: Cursor
…alization RFC - SDKInternalError class for guard clauses inside baseSubmitHandler callbacks — surfaces as inline banner instead of ErrorBoundary crash - normalizeToSDKError now parses APIError.httpMeta.body to recover structured field errors from untyped HTTP error responses (500s, 403s) - Handles both snake_case (error_key) and camelCase (errorKey) field names from raw API JSON bodies - Converts throw sites in OffCycleCreation, Profile, ContractorProfile, and PayrollConfiguration to use SDKInternalError - Adds sdkError.test.ts with 14 tests covering all normalizeToSDKError branches including body parsing edge cases - Adds RFC proposing the SDKError normalization approach Made-with: Cursor
BaseLayout was always showing the hardcoded "Unknown Error" translation for non-field, non-validation errors. Now renders error.message when available, falling back to the generic string only when message is empty. Made-with: Cursor
…xist buildApiErrorMessage now returns "N fields have issues" (or "1 field has issues") instead of echoing the first field error message. This avoids redundancy when message is displayed alongside the field error list and gives partners a consistent summary string for logging and custom UI. Made-with: Cursor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
SDKErrortype that normalizes all error scenarios (API, validation, network, internal) into a single structured shape withcategory,message,httpStatus,fieldErrors, andrawObservabilityError extends SDKErrorwithtimestamp,componentName, andcomponentStackfor telemetry — keeping the partner-facing type cleannormalizeToSDKErroris a pure function of the error type with no options — classification is based solely oninstanceofchecksuseBaseSubmit,BaseComponent,BaseLayout) to useSDKErrorfor component state and enrich with observability context only at emission sitesFederalTaxes,StateTaxes,Taxes,PaySchedule) to derive field errors fromSDKError.fieldErrorsObservabilityErrorType,ObservabilityErrorContext,createObservabilityError,includeOriginalError)This is prep work for the upcoming hooks-based architecture (#1254) where partners will interact with
SDKErrordirectly.Type Design
SDKError(partner-facing):ObservabilityError extends SDKError(telemetry):Errors displaying as expected
Field errors
SDK Internal Error
Test plan
npx tsc --noEmit)npm run build)Made with Cursor