Skip to content

fix(mongock-importer): skip IGNORED audit entries safely#932

Open
davidfrigolet wants to merge 1 commit into
masterfrom
fix/mongock-importer-ignored-null-leak
Open

fix(mongock-importer): skip IGNORED audit entries safely#932
davidfrigolet wants to merge 1 commit into
masterfrom
fix/mongock-importer-ignored-null-leak

Conversation

@davidfrigolet

Copy link
Copy Markdown
Contributor

MongockImporterMongoDB.toAuditEntry returns null for entries whose state is IGNORED (via MongockAuditEntry.shouldBeIgnored()), but the returned list is iterated downstream without a null check. Booting an application against a Mongock audit history containing an IGNORED entry therefore crashed with:

NullPointerException: Cannot invoke
"AuditEntry.getSystemChange()" because "auditEntryFromOrigin" is null

`MongockImporterMongoDB.toAuditEntry` returns `null` for entries whose
state is `IGNORED` (via `MongockAuditEntry.shouldBeIgnored()`), but the
returned list is iterated downstream without a null check. Booting an
application against a Mongock audit history containing an `IGNORED`
entry therefore crashed with:

  NullPointerException: Cannot invoke
  "AuditEntry.getSystemChange()" because "auditEntryFromOrigin" is null

inside the `migration-mongock-to-flamingock-community` system change.

Changes:

- **MongockImporterMongoDB**: filter `null`s out of the stream produced
  by `getAuditHistory()` and emit an INFO log when an entry is dropped
  because of `IGNORED`. The skipped entry's `changeId` is reported so
  operators know which legacy change was bypassed.
- **MongockImportChange**: defensive null-filter at the caller so the
  same protection applies to any current or future
  `AuditHistoryReader` implementation (Couchbase, DynamoDB).
- **MongoDBImporterTest**: regression test seeding the basic scenario
  plus one `IGNORED` entry. Asserts the `IGNORED` entry is absent from
  the Flamingock audit store and the rest of the audit history imports
  normally.

No public API change. Behavior is purely additive (null-safety + log)
relative to the previous code path.
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