DanielCarter-stack commented on issue #10470:
URL: https://github.com/apache/seatunnel/issues/10470#issuecomment-3870074299
<!-- code-pr-reviewer -->
This is a valid NPE bug. When `heartbeat.interval.ms > 0`, heartbeat records
lack the `documentKey` field, but `MongodbFetchTaskContext.isRecordBetween()`
(line 168) calls `getDocumentKey()` and uses it directly at line 171 without
null checking.
**Root cause**: `MongodbRecordUtils.extractBsonDocument()` returns `null`
when the schema doesn't contain the field (which is the case for heartbeat
records), but `isRecordBetween()` doesn't handle this null case.
**Suggested fix**: Add a null check in
`MongodbFetchTaskContext.isRecordBetween()` (lines 166-180):
```java
BsonDocument documentKey = getDocumentKey(record);
if (documentKey == null) {
return false; // skip records without documentKey (e.g., heartbeats)
}
```
**Workaround**: Set `heartbeat.interval.ms=0` to disable the heartbeat
feature until the fix is released.
Evidence files:
- `connector-cdc-mongodb/.../fetch/MongodbFetchTaskContext.java` (NPE
location)
- `connector-cdc-mongodb/.../utils/MongodbRecordUtils.java`
(`getDocumentKey` returns null)
- `connector-cdc-mongodb/.../config/MongodbIncrementalSourceOptions.java`
(heartbeat config)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]