feat(core): add error classification and default HTTP config (3/3)#1150
Draft
feat(core): add error classification and default HTTP config (3/3)#1150
Conversation
This was referenced Mar 6, 2026
Contributor
Author
|
Note: Unit tests for error classification will be added in a separate PR to keep the review focused on the implementation. |
e40db0b to
54acb5d
Compare
This was referenced Mar 6, 2026
abueide
added a commit
that referenced
this pull request
Mar 6, 2026
Adds comprehensive extended test suites for edge cases and implementation details that supplement the core tests in the feature PRs: - UploadStateMachine.extended.test.ts: disabled config, multiple retries, getter tests, persistence tests - BatchUploadManager.extended.test.ts: unique IDs, disabled config, getter tests, detailed exponential backoff algorithm tests, persistence tests - SegmentDestination.extended.test.ts: state reset after success, legacy behavior, Retry-After header parsing These tests provide thorough coverage of edge cases, backwards compatibility, and implementation details without adding bulk to the core feature PRs. Related to PRs: #1150, #1151, #1152, #1153 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Add the UploadStateMachine component for managing global rate limiting state for 429 responses, along with supporting types and config validation. Components: - RateLimitConfig, UploadStateData, HttpConfig types - validateRateLimitConfig with SDD-specified bounds - UploadStateMachine with canUpload/handle429/reset/getGlobalRetryCount - Core test suite (10 tests) and test helpers - backoff/index.ts barrel export Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add global transient error backoff manager that replaces the per-batch BatchUploadManager. Uses same exponential backoff formula from the SDD but tracks state globally rather than per-batch, which aligns with the RN SDK's queue model where batch identities are ephemeral. Components: - BackoffConfig, BackoffStateData types - Expanded HttpConfig to include backoffConfig - validateBackoffConfig with SDD-specified bounds - BackoffManager with canRetry/handleTransientError/reset/getRetryCount - Core test suite (12 tests) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add classifyError and parseRetryAfter functions for TAPI error handling, plus production-ready default HTTP configuration per the SDD. Components: - ErrorClassification type - classifyError() with SDD precedence: overrides -> 429 special -> defaults -> permanent - parseRetryAfter() supporting seconds and HTTP-date formats - defaultHttpConfig with SDD defaults (rate limit + backoff configs) - maxPendingEvents preserved (used by analytics.ts) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
9111eb7 to
0b64eba
Compare
…tion Improvements: - Add comprehensive JSDoc comments for classifyError and parseRetryAfter - Create comprehensive test suite (33 tests) covering all edge cases - Test SDD-specified error code behavior (408, 410, 429, 460, 501, 505) - Test override precedence and default behaviors - Test Retry-After parsing (seconds and HTTP-date formats) - Test edge cases (negative codes, invalid inputs, past dates) All 33 tests pass. Ready for review. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Add validation to reject negative seconds in parseRetryAfter() - Update test to verify negative values are handled correctly - Negative strings fall through to date parsing (acceptable behavior) All 33 tests pass. Ready for review. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
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
classifyError()for SDD-compliant HTTP error classificationparseRetryAfter()supporting seconds and HTTP-date formatsErrorClassificationtype totypes.tsdefaultHttpConfigtoconstants.tswith SDD defaultsmaxPendingEvents(used byanalytics.ts)Merge order
Depends on #1152. Rebase onto master after #1152 lands.
Components
classifyError() (35 lines)
Classifies HTTP status codes per the SDD error handling tables.
Precedence: statusCodeOverrides -> 429 special handling -> default4xx/5xxBehavior -> permanent fallback
Returns:
{ isRetryable, errorType: 'rate_limit' | 'transient' | 'permanent' }parseRetryAfter() (18 lines)
Parses Retry-After header values.
"60"-> 60"Fri, 31 Dec 2026 23:59:59 GMT"-> calculated delaymaxRetryInterval(default 300s)defaultHttpConfig (27 lines)
Production-ready defaults per the SDD:
Test plan
maxPendingEventsstill exported and importable