[ 
https://issues.apache.org/jira/browse/RANGER-4448?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Prashant Satam updated RANGER-4448:
-----------------------------------
    Description: 
Description: We need to handle following cases and return proper error message 
and response: # In many cases 400 or 500 is thrown, in case the use does not 
have permissions to execute the API. We need to handle such cases and throw 403 
and return proper error message.
 # In case where user is trying to enter duplicate records, the error is thrown 
with SQL query in response. In such cases, we need to throw 400 and return 
proper error message.

 

Example : 

1)On the POST API call /service/gds/resource with duplicate resources following 
error is thrown:
{code:java}
{    "statusCode": 1,    "msgDesc": "Exception [EclipseLink-4002] (Eclipse 
Persistence Services - 2.7.12.v20230209-e5c4074ef3): 
org.eclipse.persistence.exceptions.DatabaseException\nInternal Exception: 
org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique 
constraint \"x_gds_shared_resource_uk_resource_signature\"\n  Detail: Key 
(data_share_id, resource_signature)=(3, 
c5bd97fc0b8eaeb302f7498693f509178a134534cf7eb46d9edd55de71f7ab6c) already 
exists.\nError Code: 0\nCall: INSERT INTO x_gds_shared_resource (id, 
access_types, ADDED_BY_ID, additional_info, condition_expr, CREATE_TIME, 
data_share_id, description, guid, is_enabled, name, options, profiles, 
resource, resource_signature, row_filter, sub_resource_masks, 
sub_resource_names, UPDATE_TIME, UPD_BY_ID, version) VALUES (?, ?, ?, ?, ?, ?, 
?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)\n\tbind => [21 parameters bound]"} 
{code}
We need to catch such exception in create API calls and return proper response.

 

  was:
In case of GDS APIs the responses are improper for error requests

Some cases have improper errorCodes where expected ErrorCodes is 403 we get 
400,500 in response

 

Example : 

1)On the POST API call /service/gds/resource with duplicate resources following 
error is thrown:
{code:java}
{    "statusCode": 1,    "msgDesc": "Exception [EclipseLink-4002] (Eclipse 
Persistence Services - 2.7.12.v20230209-e5c4074ef3): 
org.eclipse.persistence.exceptions.DatabaseException\nInternal Exception: 
org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique 
constraint \"x_gds_shared_resource_uk_resource_signature\"\n  Detail: Key 
(data_share_id, resource_signature)=(3, 
c5bd97fc0b8eaeb302f7498693f509178a134534cf7eb46d9edd55de71f7ab6c) already 
exists.\nError Code: 0\nCall: INSERT INTO x_gds_shared_resource (id, 
access_types, ADDED_BY_ID, additional_info, condition_expr, CREATE_TIME, 
data_share_id, description, guid, is_enabled, name, options, profiles, 
resource, resource_signature, row_filter, sub_resource_masks, 
sub_resource_names, UPDATE_TIME, UPD_BY_ID, version) VALUES (?, ?, ?, ?, ?, ?, 
?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)\n\tbind => [21 parameters bound]"} 
{code}
We need to catch such exception in create API calls and return proper response.

 


> GDS CRUD APIs should return proper response and message in case of failure
> --------------------------------------------------------------------------
>
>                 Key: RANGER-4448
>                 URL: https://issues.apache.org/jira/browse/RANGER-4448
>             Project: Ranger
>          Issue Type: Sub-task
>          Components: admin
>            Reporter: Subhrat Chaudhary
>            Assignee: Prashant Satam
>            Priority: Major
>
> Description: We need to handle following cases and return proper error 
> message and response: # In many cases 400 or 500 is thrown, in case the use 
> does not have permissions to execute the API. We need to handle such cases 
> and throw 403 and return proper error message.
>  # In case where user is trying to enter duplicate records, the error is 
> thrown with SQL query in response. In such cases, we need to throw 400 and 
> return proper error message.
>  
> Example : 
> 1)On the POST API call /service/gds/resource with duplicate resources 
> following error is thrown:
> {code:java}
> {    "statusCode": 1,    "msgDesc": "Exception [EclipseLink-4002] (Eclipse 
> Persistence Services - 2.7.12.v20230209-e5c4074ef3): 
> org.eclipse.persistence.exceptions.DatabaseException\nInternal Exception: 
> org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique 
> constraint \"x_gds_shared_resource_uk_resource_signature\"\n  Detail: Key 
> (data_share_id, resource_signature)=(3, 
> c5bd97fc0b8eaeb302f7498693f509178a134534cf7eb46d9edd55de71f7ab6c) already 
> exists.\nError Code: 0\nCall: INSERT INTO x_gds_shared_resource (id, 
> access_types, ADDED_BY_ID, additional_info, condition_expr, CREATE_TIME, 
> data_share_id, description, guid, is_enabled, name, options, profiles, 
> resource, resource_signature, row_filter, sub_resource_masks, 
> sub_resource_names, UPDATE_TIME, UPD_BY_ID, version) VALUES (?, ?, ?, ?, ?, 
> ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)\n\tbind => [21 parameters 
> bound]"} {code}
> We need to catch such exception in create API calls and return proper 
> response.
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to