Skip to content

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

Merged
davidfrigolet merged 7 commits into
masterfrom
fix/mongock-importer-ignored-null-leak
Aug 6, 2026
Merged

fix(mongock-importer): skip IGNORED audit entries safely#932
davidfrigolet merged 7 commits 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.
@osantana85
osantana85 force-pushed the fix/mongock-importer-ignored-null-leak branch from 36747e2 to e938cd0 Compare July 22, 2026 11:10
`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.
…lamingock/flamingock-java into fix/mongock-importer-ignored-null-leak

@osantana85 osantana85 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments to fix before apply changes to all importers

osantana85
osantana85 previously approved these changes Aug 1, 2026

@osantana85 osantana85 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Finally I think is better to remove log messages (I added comments)

@davidfrigolet
davidfrigolet merged commit 6e9e8f3 into master Aug 6, 2026
4 checks passed
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.

2 participants