Skip to content

Fix SDK bugs found by e2e retry tests#302

Merged
didiergarcia merged 5 commits intofeat/tapi-retry-phase4-pipeline-integrationfrom
e2e-retry-fixes
Mar 24, 2026
Merged

Fix SDK bugs found by e2e retry tests#302
didiergarcia merged 5 commits intofeat/tapi-retry-phase4-pipeline-integrationfrom
e2e-retry-fixes

Conversation

@MichaelGHSeg
Copy link
Copy Markdown
Contributor

Summary

Fixes found while running e2e retry test suite against the smart retry pipeline:

EventPipeline fixes:

  • Smart retry override: RetryStateMachine.shouldDeleteBatch() replaces legacy handleUploadException for cleanup decisions — aligns with statusCodeOverrides (410/460 now retry, 501/505 now drop)
  • Case-insensitive Retry-After header lookup (OkHttp/HTTP2 lowercases response headers)
  • X-Retry-Count omitted on first attempt, sent only on retries (1, 2, 3...)
  • DropBatch decision now fires reportInternalError so errorHandler can detect dropped batches

RetryStateMachine:

  • New shouldDeleteBatch() public method for EventPipeline cleanup decisions

e2e-cli:

  • Wire errorHandler to detect delivery failures (HTTP errors, dropped batches)
  • Wire maxRetries from test config to SDK BackoffConfig
  • Clear delivery errors before each flush cycle
  • Report failure when retries exhausted or batch dropped

Test plan

  • 48/48 e2e tests pass (basic + retry suites)
  • Existing unit tests unaffected

🤖 Generated with Claude Code

analytics.log("$logTag dropping batch $url: ${decision.reason}")
val reason = decision.reason
analytics.log("$logTag dropping batch $url: $reason")
analytics.reportInternalError(
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will trigger the error handler callback when errors result in data being dropped.

Comment thread core/src/main/java/com/segment/analytics/kotlin/core/platform/EventPipeline.kt Outdated
…tion

EventPipeline fixes:
- Smart retry override: use RetryStateMachine.shouldDeleteBatch() instead
  of legacy handleUploadException for statusCodeOverrides alignment
  (410/460 now retry, 501/505 now drop)
- Case-insensitive Retry-After header lookup (OkHttp/HTTP2 lowercases)
- X-Retry-Count only sent on retries, omitted on first attempt
- DropBatch decision now reports error via reportInternalError

RetryStateMachine:
- Add shouldDeleteBatch() public method for EventPipeline cleanup decisions

e2e-cli:
- Wire errorHandler to detect delivery failures (HTTP errors, dropped batches)
- Wire maxRetries from test config to SDK BackoffConfig
- Clear delivery errors before each flush cycle
- Report failure when retries exhausted or batch dropped

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
test to ensure okhttp downcases headers.
Comment on lines +251 to +257
// Normalize status code: default to 500 for non-HTTP errors
val effectiveStatusCode = if (statusCode > 0) statusCode else 500

// In smart retry mode, override legacy cleanup with state machine decision.
if (httpConfig != null && effectiveStatusCode !in 200..299) {
shouldCleanup = retryStateMachine.shouldDeleteBatch(effectiveStatusCode)
}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So does this logic pass muster?

MichaelGHSeg and others added 2 commits March 23, 2026 16:17
Move shouldDeleteBatch decision into handleUploadException instead of
overriding cleanup after the fact with effectiveStatusCode. This avoids
the httpConfig!=null gate (which doesn't respect enabled flags) and the
null-stream edge case (statusCode=0 defaulting to 500 causing retries
instead of cleanup).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@didiergarcia didiergarcia merged commit ec8132f into feat/tapi-retry-phase4-pipeline-integration Mar 24, 2026
4 checks passed
@didiergarcia didiergarcia deleted the e2e-retry-fixes branch March 24, 2026 18:36
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