Fix unit conversion for records with primitive arrays.
Description:
Unit conversion of a record with primitive array fails with internal server error.
Record example:
{
"id": "osdu:query:85a9aad1-46b8-483d-bc01-30cca72768c4",
"kind": "osdu:ds:query:1.0.1741169207870",
"acl": {
"viewers": [
"data.test1@osdu.group"
],
"owners": [
"data.test1@osdu.group"
]
},
"legal": {
"legaltags": [
"osdu-storage-1741169207901"
],
"otherRelevantDataCountries": [
"BR"
]
},
"data": {
"GrainSizes": [
630,
35,
3
]
},
"meta": [
{
"kind": "Unit",
"name": "ft",
"persistableReference": "{\"abcd\":{\"a\":0.0,\"b\":0.001,\"c\":1.0,\"d\":0.0},\"symbol\":\"ft\",\"baseMeasurement\":{\"ancestry\":\"L\",\"type\":\"UM\"},\"type\":\"UAD\"}",
"propertyNames": [
"GrainSizes[]"
],
"unitOfMeasureID": "osdu:reference-data--UnitOfMeasure:ft:"
}
]
}
Request that fails:
curl --location 'https://community.gcp.gnrg-osdu.projects.epam.com/api/storage/v2/query/records:batch' \
--header 'Data-Partition-ID: osdu' \
--header 'frame-of-reference: units=SI;crs=wgs84;elevation=msl;azimuth=true north;dates=utc;' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer ...' \
--data '{
"records": [
"osdu:query:85a9aad1-46b8-483d-bc01-30cca72768c4"
]
}'
Response:
{
"code": 500,
"reason": "Server error.",
"message": "An unknown error has occurred."
}
Logs with error:
storage.app: Not a JSON Object: 630
AppException(error=AppError(code=500, reason=Server error., message=An unknown error has occurred., errors=null, debuggingInfo=null, originalException=java.lang.IllegalStateException: Not a JSON Object: 630), originalException=java.lang.IllegalStateException: Not a JSON Object: 630)
at org.opengroup.osdu.storage.util.GlobalOtherExceptionMapper.handleGeneralException(GlobalOtherExceptionMapper.java:35)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
........
at java.base/java.lang.Thread.run(Thread.java:840)
Caused by: java.lang.IllegalStateException: Not a JSON Object: 630
at com.google.gson.JsonElement.getAsJsonObject(JsonElement.java:165)
at org.opengroup.osdu.core.common.util.JsonUtils.getNestedJsonPropertyValueFromJsonObject(JsonUtils.java:91)
at org.opengroup.osdu.core.common.util.JsonUtils.getJsonPropertyValueFromJsonObject(JsonUtils.java:55)
How to test:
Via Storage pipeline
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
Edited by Rustam Lotsmanenko (EPAM)
Merge request reports
Activity
mentioned in merge request osdu/platform/system/lib/core/os-core-common!293 (merged)
changed milestone to %M25 - Release 0.28
added Common Code MRTesting labels
assigned to @Rustam_Lotsmanenko
mentioned in commit 70ff4bc0
picked the changes into the branch
cherry-pick-70ff4bc0
with commit 8b48657ementioned in commit 8b48657e
mentioned in merge request !1005 (merged)
Please register or sign in to reply