Docs / EventSourcingDB / Errors / last-audited-event-mismatched

last-audited-event-mismatched

The event that lastAuditedEvent names has another hash in the database.

  • Route: audit-history
  • Description: last audited event is mismatched: the event with its ID has another hash, so the events changed since the previous audit, or the anchor does not come unchanged from this database
  • Details: value, the hash of lastAuditedEvent as the request gave it.

Why It Happens#

An audit checks the chain of events from the first one on, and at the event with the ID of lastAuditedEvent, it compares the hash of that event with the one the request gives. The chain up to there is intact, since a broken chain is reported first, as event-chain-broken, but it is not the chain the previous audit saw: since every hash covers the one before it, at least one event up to that one differs from what the previous audit read.

That is the case when the events were replaced together with their hashes, but also when the anchor does not come unchanged from this database: when it comes from another database, when the database was restored from another backup since the previous audit, or when the anchor was not kept as the previous audit answered it, such as a hash of version 2 without its prefix esdb:hash:v2:.

How to Fix It#

Check that the anchor is the one the previous audit of this database answered. If it is, the events have changed since that audit, which calls for an investigation rather than another request: sending the same request again fails the same way.

Example#

For an audit anchored at the event 41, with a hash that this event does not have in the database, EventSourcingDB answers with this error, as a line of the stream, and then ends the stream with its end item:

{
  "type": "error",
  "data": {
    "code": "https://docs.eventsourcingdb.io/errors/last-audited-event-mismatched",
    "description": "last audited event is mismatched: the event with its ID has another hash, so the events changed since the previous audit, or the anchor does not come unchanged from this database",
    "details": {
      "value": "esdb:hash:v2:31483ec2de3d027913dcb424efb1b80b59994bf2e6ba7f3a2a6b00a192f4979f"
    }
  }
}