Fix batch failure in Fetch Records API when versions are missing
Description:
In GC pre-ship env we observed issues with reindexing due to a bug in batch records API. If some records in the batch do not have versions the whole batch will fail, but Storage should put them in the notFound
section and return the rest.
Details:
-
RecordMetadata
getLatestVersion
method will return null https://community.opengroup.org/osdu/platform/system/lib/core/os-core-common/-/blob/master/src/main/java/org/opengroup/osdu/core/common/model/storage/RecordMetadata.java#L80 if there are no versions. - Such record will be added to valid records to be fetched from blob storage https://community.opengroup.org/osdu/platform/system/storage/-/blob/trusted-fix-get-batch-for-dangling-records/storage-core/src/main/java/org/opengroup/osdu/storage/service/BatchServiceImpl.java#L107 However, due to the absence of a version, the record cannot be fetched, which causes the whole batch to fail.
This leads to fthe ollowing response:
{
"code": 404,
"reason": "Record version not found",
"message": "The requested record version 'null' for the record with id 'osdu:test-error-handling:third' was not found"
}
After adding a null check for latest version, we see that valid records from the batch are present in a response and not valid are in the not found section:
....
}
],
"notFound": [
"osdu:test-error-handling:third"
],
"conversionStatuses": []
}
How to test:
Does functionality was tested and how?
Changes include:
-
Refactor (a non-breaking change that improves code maintainability). -
Bugfix (a non-breaking change that solves an issue). -
New feature (a non-breaking change that adds functionality). -
Breaking change (a change that is not backward-compatible and/or changes current functionality).
Changes in:
-
Common code
Dev Checklist:
-
Added Unit Tests, wherever applicable. -
Updated the Readme, if applicable. -
Existing Tests pass -
Verified functionality locally -
Self Reviewed my code for formatting and complex business logic.
Other comments:
Any comments to approvers here
Merge request reports
Activity
changed milestone to %M25 - Release 0.28
added MRBugfix label
assigned to @Rustam_Lotsmanenko
added Common Code label
mentioned in commit 207a6343
picked the changes into the branch
cherry-pick-207a6343
with commit 4a43189amentioned in commit 4a43189a
mentioned in merge request !1011 (merged)