Skip to content

fix: add schema version field to Event type for backward-compatible evolution - #1426

Open
ravimahatonp wants to merge 1 commit into
CodeGirlsInc:mainfrom
ravimahatonp:fix/event-versioning-1382
Open

ravimahatonp wants to merge 1 commit into
CodeGirlsInc:mainfrom
ravimahatonp:fix/event-versioning-1382

Conversation

@ravimahatonp

Copy link
Copy Markdown

Summary

Closes #1382

Problem

Events defined in event.rs have no version field. Adding or removing fields later risks breaking existing webhook consumers and audit log parsers that expect a fixed shape, with no way to distinguish between schema revisions.

Solution

  • Added a version: u32 field to the Event struct with #[serde(default = "default_version")], defaulting to 1.
  • New events created via Event::new() are stamped with version: 1.
  • Legacy events serialized without a version field deserialize cleanly with the default, ensuring full backward compatibility.
  • Added 2 new tests:
    • test_version_in_serialized_json — verifies version appears in JSON output.
    • test_backward_compat_missing_version_defaults_to_1 — verifies legacy JSON without version deserializes to version 1.
  • Updated existing tests to assert version == 1.

Why #[serde(default)]?

This ensures that any previously persisted events (e.g., in Redis audit trail) that lack the version key can still be deserialized without errors, defaulting to schema version 1.

@vercel

vercel Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

@ravimahatonp is attempting to deploy a commit to the Mftee's projects Team on Vercel.

A member of the Team first needs to authorize it.

This branch has not been deployed

No deployments
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.

Event types are not versioned

1 participant