Skip to content

Fix AwaitMessageTrigger crash on tombstone messages when apply_function is unset#69665

Open
TimurRakhmatullin86 wants to merge 1 commit into
apache:mainfrom
TimurRakhmatullin86:fix/kafka-trigger-tombstone-null-value
Open

Fix AwaitMessageTrigger crash on tombstone messages when apply_function is unset#69665
TimurRakhmatullin86 wants to merge 1 commit into
apache:mainfrom
TimurRakhmatullin86:fix/kafka-trigger-tombstone-null-value

Conversation

@TimurRakhmatullin86

Copy link
Copy Markdown

When AwaitMessageTrigger is used without an apply_function (supported since #55437), the trigger calls message.value().decode("utf-8") on every polled message. For a tombstone message — value() is None, a routine occurrence on log-compacted topics where a null value is the deletion marker — this raises AttributeError: 'NoneType' object has no attribute 'decode', crashing the trigger and failing the deferred task.

This PR treats a tombstone the same way as any other non-matching message: no event is emitted, the offset is committed (when commit_offset=True, matching the existing non-matching path so the tombstone is not re-read forever after a restart), and the trigger keeps polling.

Why skip rather than emit: the trigger's contract is already truthiness-based (if event:), so a None payload cannot be yielded on this path today, and a TriggerEvent(None) would carry no usable payload downstream. Users who need to react to tombstones can already do so via apply_function, which receives the raw message (including value() is None) and can map it to any truthy payload. Surfacing tombstones from the no-apply_function convenience path would be a separate opt-in feature; crashing on them is a bug.

Tests:

  • test_trigger_run_tombstone_message_keeps_polling — regression test: poll() returns a null-value message; asserts the trigger neither raises nor yields and commits the tombstone offset. Fails on main with the exact AttributeError above.
  • test_trigger_run_without_apply_function_yields_message_value — asserts the happy path still yields the decoded payload.
  • MockedMessage now has a value() method: the apply_function=None case of test_trigger_run_good previously passed for the wrong reason — the mock lacked value(), so the task finished via this same AttributeError, satisfying task.done() is True.

No behavior change for non-null messages or when apply_function is set. Empty (b"") payloads were already treated as non-events by the if event: check — unchanged.

…on is unset

Signed-off-by: Timur Rakhmatullin <174210871+TimurRakhmatullin86@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant