fix: HTTP exception classification — separate permanent from retriable failures#44
Merged
Merged
Conversation
…e failures Previously, a single generic catch (e: Exception) mapped all errors to RetriableFailure. Corrupt delivery metadata or an unknown service therefore triggered an infinite retry loop instead of moving the entry to FAILED. Now classified explicitly: - JsonProcessingException (corrupt metadata) → PermanentFailure (caught before IOException — it's a subtype) - IOException (connection/timeout) → RetriableFailure - InterruptedException → RetriableFailure (interrupt flag restored, consistent with KafkaMessageDeliverer) - other Exception (malformed URI, unknown service, IllegalStateException from ServiceUrlResolver) → PermanentFailure Adds two unit tests covering the new classification paths: - corrupt delivery metadata → PermanentFailure - urlResolver throwing → PermanentFailure
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
HttpMessageDeliverer.deliver()previously caught all exceptions asRetriableFailure. This meant corrupt delivery metadata or an unknown service triggered an infinite retry loop instead of moving the entry toFAILED.This PR classifies exceptions explicitly:
JsonProcessingExceptionPermanentFailureIOException— it's a subtype)IOExceptionRetriableFailureInterruptedExceptionRetriableFailureKafkaMessageDelivererExceptionPermanentFailureIllegalStateExceptionfromServiceUrlResolver, etc.Why this matters
Before:
okapi-httpconsumer with malformed JSON indeliveryMetadata→ infinite retries → retry storm in logs, entry never markedFAILED, operator alert fatigue.After: corrupt input →
PermanentFailure→ entry moves toFAILEDperRetryPolicy, ops visibility preserved.Scope
HttpMessageDeliverer.kt: refactor to expression-body, granularcatchblocks, updated KDocHttpMessageDelivererTest.kt: 2 new testsPermanentFailure(does not throw)urlResolverthrowing →PermanentFailure(does not throw)Independent of the Kafka
deliverBatchwork in PR #40.Test plan
./gradlew :okapi-http:test ktlintCheck— all 13 unit tests pass (11 existing + 2 new)