Update PartitionService.java, will fix invaliddata-partition-id return 500 code
Resolving issue #70
While making calls to OSDU services, such as secret
and storage
service, testers discover that if they put invalid symbols in data_partition_id
, we will have 500 code, but with reason of Access Denied.
After investigation, we realize the partition service did not consider the situation that user put invalid URI symbols like @#$%
in data partition
id, which will make the normalizeStringUrl
function have Java.Lang exception in this UrlNormalizationUtil.java.
Caused by: java.lang.IllegalArgumentException: Malformed escape pair at index 57: http://os-partition:8080/api/partition/v1/partitions/osdu%
at java.net.URI.create(URI.java:852)
at org.opengroup.osdu.core.common.util.UrlNormalizationUtil.normalizeStringUrl(UrlNormalizationUtil.java:27)
This will generate a 500 code in entitlement service since the service will treat this error as a general error in SpringExceptionMapper.java, instead a 400 code.
So as an optional solution, a try-catch will handle the exception within normalizeStringUrl
function and return a AppException
so the service will know what it is.