> On Sept. 21, 2022, 4:38 p.m., Madhan Neethiraj wrote: > > The patch looks good. One suggestion: instead of multiple exception mappers > > (GenericRangerJsonMappingExceptionMapper and > > GenericRangerJsonParserExceptionMapper), how about using a single mapper - > > similar to > > https://github.com/apache/ranger/blob/master/kms/src/main/java/org/apache/hadoop/crypto/key/kms/server/KMSExceptionsProvider.java?
KMSExceptionsProvider looks very generic.But we need to handle only invalid jsonformat,invalid attribute in valid json body.Inside generic exception anyway we need to cast the generic exception into JsonParseException or JsonMappingException ,etc.To make it clean i created mapper for specific exception which we are looking into it. - Ramachandran ----------------------------------------------------------- This is an automatically generated e-mail. To reply, visit: https://reviews.apache.org/r/74135/#review224695 ----------------------------------------------------------- On Sept. 21, 2022, 4:26 p.m., Ramachandran Krishnan wrote: > > ----------------------------------------------------------- > This is an automatically generated e-mail. To reply, visit: > https://reviews.apache.org/r/74135/ > ----------------------------------------------------------- > > (Updated Sept. 21, 2022, 4:26 p.m.) > > > Review request for ranger, Abhay Kulkarni, Madhan Neethiraj, Nikhil P, > Pradeep Agrawal, Ramesh Mani, Selvamohan Neethiraj, Sailaja Polavarapu, and > Velmurugan Periasamy. > > > Bugs: RANGER-3847 > https://issues.apache.org/jira/browse/RANGER-3847 > > > Repository: ranger > > > Description > ------- > > In Ranger rest API if you pass an Invalid attribute type in the JSON request > body, it throws a 404 error instead of 400 (Bad Request). It seems a bug > where we need to handle the JsonMappingException by adding Exception Mapper > globally to handle incorrect JSON format or Invalid attribute type in the > JSON request body otherwise our Rest API will throw a 404 error instead of > 400 error > > > Diffs > ----- > > > security-admin/src/main/java/org/apache/ranger/common/GenericRangerJsonMappingExceptionMapper.java > PRE-CREATION > > security-admin/src/main/java/org/apache/ranger/common/GenericRangerJsonParserExceptionMapper.java > PRE-CREATION > > > Diff: https://reviews.apache.org/r/74135/diff/1/ > > > Testing > ------- > > Request with proper request : Passing int values > > curl --location --request POST > 'https://----------------/service/xaudit/trx_log' \ > --header 'Authorization: Basic XXXX=' \ > --header 'Accept: application/json' \ > --header 'Content-Type: application/json' \ > --data-raw '{ > "objectClassType" : "123456", > "objectId" : "1234567" > }' > > Response : ok > > > Request with bad request : Passing String values > > curl --location --request POST 'https://---------/service/xaudit/trx_log' \ > --header 'Authorization: Basic XXXXX==' \ > --header 'Accept: application/json' \ > --header 'Content-Type: application/json' \ > --data-raw '{ > "objectClassType" : "abcdef", > "objectId" : "abcdef" > }' > > Response : > { > "errorCode": "Bad Request", > "error": "Can not construct instance of int from String value 'abcdef': not > a valid Integer value\n at [Source: > org.apache.catalina.connector.CoyoteInputStream@2c444edc; line: 1, column: 2] > (through reference chain: > org.apache.ranger.view.VXTrxLog[\"objectClassType\"])" > } > > > Thanks, > > Ramachandran Krishnan > >
