All problems

Audit Log Snapshot Changes After Later Object Mutation

Level 2 · node · Data · Audit log corruption from shallow copy

Scenario

A customer-settings service stores before and after snapshots in an audit log. Changes to string fields are recorded correctly, but operations reports that changing a nested notification value on the same settings object after recording also changes the after value in an existing audit entry. The update service, settings repository, and audit repository are separated.

Requirements

- Audit before and after values are independent snapshots of the state at record time - Changing the original settings object after recording must not alter an existing audit entry - Nested object values must preserve their recorded state - When multiple changes are recorded, every entry keeps an independent snapshot - Mutating a value returned by audit-log lookup must not change the stored log

Acceptance criteria

  • Before and after values for a simple field change are recorded correctly
  • Changing a nested value on the original object after recording does not change the existing after snapshot
  • The nested value in the before snapshot is also independent from later changes
  • Two consecutive audit entries preserve the state from their respective points in time
  • Mutating a lookup result and reading again leaves the stored audit log unchanged