Skip to content

Closes #23463: Include ObjectChange IDs in event data and webhook payloads - #23497

Merged
pheus merged 2 commits into
mainfrom
23463-include-objectchange-ids-in-events
Oct 27, 2026
Merged

pheus merged 2 commits into
mainfrom
23463-include-objectchange-ids-in-events

Conversation

@jeremystretch

@jeremystretch jeremystretch commented Oct 26, 2026 •

Copy link
Copy Markdown
Member

Closes: #23463

Queued object events now carry the IDs of the change log records behind them, so webhooks and EVENTS_PIPELINE consumers can tie an event to its changelog entries.

  • The change logging signal handlers pass the ID of the ObjectChange they record (or update, for M2M changes) to enqueue_event(), which takes a new optional object_change_id argument.
  • Each queued event gets an object_change_ids list. Changes to the same object within a request are coalesced into one event, so the list can hold several IDs, in the order they were recorded and without duplicates. A save that records no change adds nothing.
  • The webhook action passes the list through to send_webhook(), which adds object_change_ids to the webhook context when it's not empty, the same way snapshots is handled. Job events never have one.
  • Updated the webhook docs (available context, default body example, and the context table).

This follows the implementation proposed in the issue, plus the pass-through to webhooks (the issue's diff stops at the event queue). The list is created when an event is first queued, instead of using setdefault() when events are coalesced.

The change is additive: enqueue_event() and send_webhook() only gain optional arguments, and webhook jobs already queued before an upgrade still run. The reverse isn't fully covered: a worker still running older code will reject a webhook job that carries object_change_ids. To keep that window small, the argument is only passed when there are IDs to send.

Tests: extended the create/update/delete event rule tests to check the IDs against the recorded ObjectChange. Added tests for a coalesced event (create, update, M2M change and a no-op save in one request), for the webhook body, and for omitting the key when there are no IDs. I also checked it end to end against a scratch instance: created, updated, no-op-updated and deleted a site through the REST API, and in each webhook received, object_change_ids matched the changelog entry for the same request (the no-op update had none). The full test suite, ruff check, makemigrations --check and the docs build all pass.

- Pass object_change_ids to send_webhook() only when it's non-empty, so
  job events and no-op saves don't send the new kwarg to older workers
- Tolerate queued events which lack an object_change_ids list
- Filter ObjectChanges by object type as well as ID in tests
@jeremystretch
jeremystretch marked this pull request as ready for review October 26, 2026 16:37
@jeremystretch
jeremystretch requested review from a team and bctiemann and removed request for a team October 26, 2026 16:37
@pheus
pheus requested review from pheus and removed request for bctiemann October 27, 2026 13:14

@pheus pheus left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks! This looks good to me.

@pheus
pheus merged commit 68d403c into main Oct 27, 2026
19 checks passed
@pheus
pheus deleted the 23463-include-objectchange-ids-in-events branch October 27, 2026 13:20
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.

Include ObjectChange ID(s) in event data and webhook payloads

2 participants