Skip to content

Add an option to continue processing on deserialization errors#514

Merged
loicgreffier merged 2 commits intomichelin:mainfrom
AnkurSinhaaa:feat(dlq)-add-continue-on-unhandled-errors-for-deserialization-handler
Apr 15, 2026
Merged

Add an option to continue processing on deserialization errors#514
loicgreffier merged 2 commits intomichelin:mainfrom
AnkurSinhaaa:feat(dlq)-add-continue-on-unhandled-errors-for-deserialization-handler

Conversation

@AnkurSinhaaa
Copy link
Copy Markdown
Contributor

feat(dlq): add continue-on-unhandled-errors for deserialization handler

  • Introduced new configuration dlq.deserialization-handler.continue-on-unhandled-errors
  • When enabled, all unhandled deserialization exceptions are routed to DLQ and processing continues
  • Preserves existing behavior by default (false)

Refactoring:

  • Extracted logic into helper methods (shouldResume, buildKafkaError, serializeError, resumeWithDlqRecord)
  • Removed duplication in DLQ response creation
  • Improved readability and separation of concerns in handler

Tests:

  • Added unit tests for new configuration (enabled/disabled scenarios)
  • Ensured backward compatibility with existing tests

@loicgreffier loicgreffier changed the title #507 Optional DLQ routing for all deserialization errors without shut… Add an option to continue processing on deserialization errors Apr 15, 2026
@loicgreffier loicgreffier added the feature This issue or pull request contains a new feature label Apr 15, 2026
Copy link
Copy Markdown
Collaborator

@loicgreffier loicgreffier left a comment

Choose a reason for hiding this comment

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

@AnkurSinhaaa Here's my review with some minor code refactoring.

BTW I'm wondering if we should also add a property to resume without forwarding anything to DLQ. We might want to continue and simply drop the records sometimes.

}

return Response.fail();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Remove this extra-line


boolean shouldResume = shouldResume(exception);

if (shouldResume) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think the final return logic in this handler could be simplified as follows:

boolean shouldResumeWithDlq = shouldResume(exception);
return shouldResumeWithDlq ? resumeWithDlqRecord(consumerRecord, value) : Response.fail();

If the continueOnUnhandledErrors verification is included in the shouldResume function (see my comment https://github.com/michelin/kstreamplify/pull/514/changes#r3086483677)

@AnkurSinhaaa
Copy link
Copy Markdown
Contributor Author

AnkurSinhaaa commented Apr 15, 2026

Thanks for the suggestions @loicgreffier

I’ve moved continueOnUnhandledErrors into the shouldResume method and simplified the return logic:

return shouldResume(exception)
? resumeWithDlqRecord(...)
: Response.fail();

This centralizes the decision logic and removes duplication.

Also agreed on the idea of supporting a "drop without DLQ" mode — that would be a useful addition, But the question is DLQ usage ? My personal opinion is to keep traces of dropped records for monitoring and debugging. I suggest introducing it as a separate configuration (e.g. drop-on-error) in a follow-up issue and PR to keep this change focused if we end up to finalize that we don't need them in dlq.

@loicgreffier
Copy link
Copy Markdown
Collaborator

@AnkurSinhaaa

I suggest introducing it as a separate configuration

Agree, resume and send to DLQ should remain the default. A "resume and drop" behavior should be controlled by a separate property

@loicgreffier loicgreffier merged commit 8085b35 into michelin:main Apr 15, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature This issue or pull request contains a new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants