Fix #427: preserve original event timestamp in Event.forward#705
Open
wbarnha wants to merge 1 commit into
Open
Fix #427: preserve original event timestamp in Event.forward#705wbarnha wants to merge 1 commit into
wbarnha wants to merge 1 commit into
Conversation
Event.forward already defaults key, value and headers to the original message via USE_EXISTING_* sentinels, but timestamp defaulted to None, so the forwarded message got a fresh (send-time) timestamp. Stream.group_by forwards events internally, so grouping silently dropped the event time and broke downstream event-time windowing. Add a USE_EXISTING_TIMESTAMP sentinel and default forward's timestamp to self.message.timestamp, consistent with the other forwarded fields. message.timestamp is in seconds, the same unit send() expects, so it round-trips correctly. Passing an explicit timestamp (including None) still overrides. Closes #427. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HHPL4VFWQRQPpjR1gXSKyL
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #705 +/- ##
==========================================
+ Coverage 94.14% 94.15% +0.01%
==========================================
Files 104 104
Lines 11136 11139 +3
Branches 1201 1202 +1
==========================================
+ Hits 10484 10488 +4
+ Misses 551 550 -1
Partials 101 101 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
wbarnha
added a commit
that referenced
this pull request
Jul 19, 2026
Per review, the v0.12.0 changelog/release notes should describe only what is already on master, not work still in open PRs. - Remove the not-yet-merged items: the offset-commit data-loss fixes (#606/#707, #316/#692), the optional OpenTracing/OpenTelemetry extras (#685/#686, #688/#681), web_application_options (#704), and the reported-issue fix stack (#693-#703, #705). These will be added back as they merge. - Add a Dependencies section noting the current runtime/client libraries: mode-streaming >= 0.4.0, aiokafka >= 0.10.0 (compatible with recent 0.13/0.14 releases), the new confluent-kafka >= 2.0.0 for faust[ckafka], and the faust-cchardet fork replacing unmaintained cchardet. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HHPL4VFWQRQPpjR1gXSKyL
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.
What
Event.forwardre-sends the original message ("will not be reserialized"), and already defaultskey,valueandheadersto the original message viaUSE_EXISTING_*sentinels. Buttimestampdefaulted toNone, so the forwarded message received a fresh send-time timestamp instead of the original event time.Stream.group_byforwards events internally, so grouping silently dropped the event timestamp — breaking downstream event-time windowing (the user has to rebuild the partitioning key by hand to keep the timestamp).Closes #427.
How
USE_EXISTING_TIMESTAMPsentinel alongside the existingUSE_EXISTING_KEY/USE_EXISTING_VALUE/USE_EXISTING_HEADERS.Event.forwardnow defaultstimestamptoself.message.timestamp, consistent with how it already treats the other forwarded fields.message.timestampis stored in seconds (the consumer divides the Kafka record's millisecond timestamp by 1000), which is the same unitsend()expects (it multiplies back by 1000), so the value round-trips correctly. Passing an explicittimestamp— includingNone— still overrides, so callers keep full control.Test
Added
test_forward__default_timestamp_preservedintests/unit/test_events.py: with notimestampargument, assertsforwardpassesself.message.timestampthrough to_send. The existingtest_forward(explicit timestamp) andtest_forward__USE_EXISTING_KEY_VALUE(explicittimestamp=None) still pass unchanged, confirming explicit values are respected. Fulltests/unit/test_events.pypasses (9 passed); events +group_by/forward stream tests green (17 passed).🤖 Generated with Claude Code
Generated by Claude Code