feat(core): add config validation, defaults, and httpConfig extraction#1157
Merged
feat(core): add config validation, defaults, and httpConfig extraction#1157
Conversation
2 tasks
d6f2a89 to
915c8e3
Compare
7a0b957 to
f631f9f
Compare
eedad38 to
36997ac
Compare
04bb992 to
658e649
Compare
1a577e8 to
c451d38
Compare
3a16620 to
f3e71c3
Compare
b1cd5f5 to
ff837e7
Compare
f3e71c3 to
55221f4
Compare
ff837e7 to
a3ac0e5
Compare
09d48d7 to
a6127cc
Compare
f76fd78 to
e1fb9cd
Compare
Add config validation utilities (validateRateLimitConfig, validateBackoffConfig), default HTTP config constants, and httpConfig extraction/merging logic in SegmentClient.fetchSettings(). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Deep-merge statusCodeOverrides so server-sent partial overrides don't replace defaults. Add rateLimitConfig parameter to validateBackoffConfig for the cross-config relational constraint: maxTotalBackoffDuration >= 2x max(maxBackoffInterval, maxRetryInterval). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… validation Remove autoFlushOnRetryReady from defaultConfig (redundant with TimerFlushPolicy). Validate integrations field from CDN response before storing — falls back to defaultSettings when CDN returns null, array, or non-object integrations. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
e1fb9cd to
d0f997b
Compare
retryStrategy was removed from Config type in #1156, but remained in defaultConfig causing build errors. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When CDN returns a valid 200 with no integrations field (e.g. {}),
treat it as authoritative "no integrations configured" rather than
falling back to defaultSettings. This ensures SegmentDestination is
correctly disabled when the server has no integrations.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Extract complex logic into focused helper methods: - validateIntegrations(): handles normalization and validation - extractHttpConfig(): handles merge and validation of httpConfig - applyDefaultSettings(): consolidates fallback logic This reduces fetchSettings from 98 lines to ~50 lines and improves testability by isolating each concern. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Move validateIntegrations and extractHttpConfig from SegmentClient private methods to exported functions in config-validation.ts. This keeps analytics.ts slimmer and groups all config-related validation logic in one place. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
MichaelGHSeg
approved these changes
Mar 23, 2026
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
validateRateLimitConfig()andvalidateBackoffConfig()utilities that clamp config values to safe ranges with logger warningsdefaultHttpConfigwith SDD-compliant defaults (status code overrides: 408/410/429/460→retry, 501/505→drop)httpConfigfield toSegmentClientwithgetHttpConfig()accessorhttpConfigfrom CDN response infetchSettings(), validating and clamping valuesstatusCodeOverridesso server-sent partial overrides extend defaults rather than replacing themmaxTotalBackoffDuration >= 2x max(maxBackoffInterval, rateLimitConfig.maxRetryInterval){}(authoritative "no integrations") rather than falling back to defaultSettingsPR 2 of 5 in the TAPI backoff/retry stack. Depends on #1156.
Test plan
statusCodeOverrides: { '501': 'drop' }preserves default overrides for 408, 410, 429, 460, 505validateBackoffConfigcross-checks againstrateLimitConfig.maxRetryInterval{}or{integrations: null}correctly stores empty integrations (disables SegmentDestination)🤖 Generated with Claude Code