-
Type: Bug
-
Status: Resolved
-
Priority: Major
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: ML Data Enrichment
We're encountering a NullPointerException within SaveEnrichmentFunction when there are corrupted documents, documents without base versions.
We've created a fix to check for corrupt documents by checking if a document base version exists: https://github.com/nuxeo/nuxeo-ai/pull/597
In more details, we have encountered a NullPointerException within SaveEnrichmentFunction. This was a result of corrupted documents where the documents did not have base versions. This change makes an improvement to the class. We now check if the base version is null and if it is null and the document is not checked out, we exit, returning null. Additionally, this change improves logging within the class, adding an error log for unexpected exceptions along with a couple other logs. The class also had a couple small refactors as well.
The !doc.isCheckedOut() check was added in dd3b862 (see - 14648a99f3c449402bab08e28f3c4c6c78495c30..dd3b862658a35f863a8a0ab7b85739af3a58b189 (compare) ), because there are valid cases where documents do not have base versions (such as a document that was never versioned). The check before was too strong and was causing one of our tests to fail, as shown below.
This change relates to the code path from the exception where a document is checked in and the versioning service tries to check out the document but fails as there isn't a base version:
For a description of the isCheckedOut(), please see here:
The test failure was the following:
{{java.lang.AssertionError: The document must have the enrichment facet
at org.junit.Assert.fail(Assert.java:88)
at org.junit.Assert.assertTrue(Assert.java:41)
at org.nuxeo.ai.enrichment.TestConfiguredStreamProcessors.testConfiguredStreamProcessor(TestConfiguredStreamProcessors.java:135)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)}}
( #597 (checks) )
```
java.lang.NullPointerException: null at org.nuxeo.ecm.core.versioning.StandardVersioningService.doCheckOut(StandardVersioningService.java:374) ~[nuxeo-core-10.10-HF71.jar:?] at org.nuxeo.ecm.core.versioning.StandardVersioningService.doPreSave(StandardVersioningService.java:325) ~[nuxeo-core-10.10-HF71.jar:?] at org.nuxeo.ecm.core.versioning.VersioningComponent.doPreSave(VersioningComponent.java:423) ~[nuxeo-core-10.10-HF71.jar:?] at org.nuxeo.ecm.core.api.AbstractSession.saveDocument(AbstractSession.java:1613) ~[nuxeo-core-10.10-HF71.jar:?] at org.nuxeo.ai.functions.SaveEnrichmentFunction.lambda$null$0(SaveEnrichmentFunction.java:49) ~[nuxeo-ai-core-2.7.19.jar:?] at org.nuxeo.ecm.core.api.CoreInstance$1.run(CoreInstance.java:186) ~[nuxeo-core-api-10.10-HF71.jar:?]
```
Also note, we ran into a couple flaky errors within the workflow, first BulkEnrichmentTest.shouldNotBacktrackConfirmedValue and then AnnotationConfirmTest.shouldNotBacktrackConfirmedValue. The third attempt passed - nuxeo/nuxeo-ai/actions/runs/4820357966. I don't think this change caused this flakyness, but it's something we should improve in the future.
- is related to
-
AICORE-617 Forward integrate nuxeo-ai LTS 2019 changes to master for LTS 2021
- Resolved