Skip to content

fix(events): require valid data.timestamp at ingest (HTTP 400)#30

Closed
colombod wants to merge 1 commit into
mainfrom
fix/events-require-timestamp
Closed

fix(events): require valid data.timestamp at ingest (HTTP 400)#30
colombod wants to merge 1 commit into
mainfrom
fix/events-require-timestamp

Conversation

@colombod

Copy link
Copy Markdown
Collaborator

Problem: /events accepted events missing data.timestamp with 202, but the durable graph drainer later crashed (datetime.fromisoformat('')), retried, and dead-lettered them — a silent data loss (caller saw success, no node landed). Surfaced during the live Entra AC10 end-to-end run.

Fix (Option A — reject at the boundary):

  • post_events validates data.timestamp (present, non-empty string, valid ISO-8601) BEFORE queuing → HTTP 400 with a clear, value-naming message.
  • make_node_id re-raises a NAMED error (event + session) so anything that ever bypasses ingest dead-letters legibly instead of as a bare Invalid isoformat string.

Safe against real traffic: a scan of 224,530 real events across 759 on-disk records found 0 missing data.timestamp — the 400 only catches malformed/hand-rolled payloads.

11 new tests (8 HTTP-level 400 cases + 3 drainer-guard); 15 pre-existing /events tests that were sending timestamp-less payloads updated to well-formed bodies (assertions unchanged). Full suite 1376 green. Independent of the Entra auth PR (#29).

…silent dead-letter

The /events endpoint accepted events whose data.timestamp was missing/empty (202,
created_by stamped) but the durable drainer then crashed building the graph node
(datetime.fromisoformat('') -> ValueError), retried, and dead-lettered them -- no node,
and no error surfaced to the caller. Now:
- post_events validates data.timestamp is present, a non-empty string, and valid
  ISO-8601 BEFORE queuing; otherwise HTTP 400 with a clear, value-naming message.
- make_node_id wraps the parse and re-raises a NAMED error (event + session in the
  message) so any malformed event that bypasses ingest dead-letters legibly, not as a
  bare 'Invalid isoformat string'.

Verified safe against real traffic: 224,530 real events across 759 on-disk records all
carry data.timestamp, so the 400 only catches malformed/hand-rolled payloads (the gap
surfaced in the live AC10 run). 11 new tests; 15 pre-existing /events tests that sent
timestamp-less payloads updated to well-formed bodies (assertions unchanged). Suite 1376 green.

🤖 Generated with [Amplifier](https://github.com/microsoft/amplifier)

Co-Authored-By: Amplifier <240397093+microsoft-amplifier@users.noreply.github.com>
@colombod

Copy link
Copy Markdown
Collaborator Author

Folded into #29. The fix (data.timestamp ingest validation -> HTTP 400, plus the make_node_id named-error guard) was cherry-picked onto feat/entra-auth and is now part of PR #29. Closing this in favor of the single PR; the work is not lost.

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.

1 participant