Skip to content

Fix null message_type causing NOT NULL violation when dead-lettering …#2306

Merged
jeremydmiller merged 1 commit intoJasperFx:mainfrom
lahma:kafka-dead-letters
Mar 16, 2026
Merged

Fix null message_type causing NOT NULL violation when dead-lettering …#2306
jeremydmiller merged 1 commit intoJasperFx:mainfrom
lahma:kafka-dead-letters

Conversation

@lahma
Copy link
Copy Markdown
Contributor

@lahma lahma commented Mar 16, 2026

…CloudEvents with unregistered types

When a Kafka CloudEvents message arrives with an unregistered type, CloudEventsMapper throws UnknownMessageTypeNameException before setting envelope.MessageType. The subsequent dead-letter INSERT hits a NOT NULL violation on message_type, causing an infinite retry loop.

Layered fix:

  • CloudEventsMapper: preserve raw CloudEvent type on envelope before attempting resolution, so the original type identity survives for dead-letter persistence
  • MoveToErrorQueue: add fallback guard that assigns a sentinel message type (unknown/{ExceptionName}) when Message is null and MessageType was never set
  • DatabasePersistence: null-coalesce MessageType to "unknown" in the dead-letter INSERT as a belt-and-suspenders defense

Triggered by #2308 .

@lahma lahma force-pushed the kafka-dead-letters branch 2 times, most recently from 9b94f74 to 3889b54 Compare March 16, 2026 13:31
@lahma
Copy link
Copy Markdown
Contributor Author

lahma commented Mar 16, 2026

Main seems to have the failing tests.

@lahma lahma marked this pull request as ready for review March 16, 2026 13:46
…CloudEvents with unregistered types

When a Kafka CloudEvents message arrives with an unregistered `type`,
CloudEventsMapper throws UnknownMessageTypeNameException before setting
envelope.MessageType. The subsequent dead-letter INSERT hits a NOT NULL
violation on message_type, causing an infinite retry loop.

Layered fix:
- CloudEventsMapper: preserve raw CloudEvent type on envelope before
  attempting resolution, so the original type identity survives for
  dead-letter persistence
- MoveToErrorQueue: add fallback guard that assigns a sentinel
  message type (unknown/{ExceptionName}) when Message is null and
  MessageType was never set
- DatabasePersistence: null-coalesce MessageType to "unknown" in the
  dead-letter INSERT as a belt-and-suspenders defense
@lahma lahma force-pushed the kafka-dead-letters branch from 3889b54 to 56513a5 Compare March 16, 2026 16:34
@jeremydmiller
Copy link
Copy Markdown
Member

Yuck, yeah, I'll get this in now. Thank you!

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