You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ranger.apache.org by "Sanket-Shelar (via GitHub)" <gi...@apache.org> on 2026/08/04 11:35:46 UTC

[PR] RANGER-5729: Unable to import exported GDS policies via Service Manag… [ranger]

Sanket-Shelar opened a new pull request, #1125:
URL: https://github.com/apache/ranger/pull/1125

   …er due to 403 Error
   
   ## What changes were proposed in this pull request?
   
   Governed Data Sharing (GDS) policies are designed to be managed exclusively through GDS APIs. However, they were inadvertently being included when exporting policies from the Report page. When users attempted to import these files back through the Service Manager, it resulted in a 403 error.
   
   This patch resolves the issue by aligning the export and import behaviors:
   
   Export Updates: GDS policies are now automatically excluded when exporting policies (JSON, CSV, or Excel).
   
   Import Updates: If a user imports a legacy file that still contains GDS policies, the system will now safely skip the GDS policies (logging a helpful warning) rather than failing the entire import. This ensures that non-GDS policies, like Hive, continue to import successfully.
   
   
   ## How was this patch tested?
   
   Created both GDS objects (datashares, datasets, policies) and non-GDS policies (Hive).
   
   Exported policies from the Report page and verified that GDS policies are no longer included in the file.
   
   Imported the newly exported file via Service Manager and confirmed it succeeds without a 403 error.
   
   Imported a legacy export file containing GDS policies to verify that non-GDS policies import correctly while GDS policies are cleanly skipped and logged.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@ranger.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] RANGER-5729: Unable to import exported GDS policies via Service Manag… [ranger]

Posted by "Sanket-Shelar (via GitHub)" <gi...@apache.org>.
Sanket-Shelar commented on code in PR #1125:
URL: https://github.com/apache/ranger/pull/1125#discussion_r3718705598


##########
security-admin/src/main/java/org/apache/ranger/rest/ServiceREST.java:
##########
@@ -3833,24 +3839,26 @@ private List<RangerPolicy> getAllFilteredPolicyList(SearchFilter filter, HttpSer
 
         if (!CollectionUtils.isEmpty(policyLists)) {
             for (RangerPolicy policy : policyLists) {
-                if (policy != null) {
+                if (policy != null && !isGdsPolicy(policy)) {
                     //set createTime & updateTime Time as null since exported policies dont need this
                     policy.setCreateTime(null);
                     policy.setUpdateTime(null);
 
                     orderedPolicies.put(policy.getId(), policy);
                 }
             }
-            if (!orderedPolicies.isEmpty()) {
-                policyLists.clear();
 
-                policyLists.addAll(orderedPolicies.values());
-            }
+            policyLists.clear();
+            policyLists.addAll(orderedPolicies.values());
         }
 
         return policyLists;
     }
 
+    private boolean isGdsPolicy(RangerPolicy policy) {
+        return EMBEDDED_SERVICEDEF_GDS_NAME.equals(policy.getServiceType()) || ServiceDBStore.GDS_SERVICE_NAME.equals(policy.getService());

Review Comment:
   It was added as an additional check, in case serviceType is not present. I have udpated the condition to only check for serviceType match.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@ranger.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] RANGER-5729: Unable to import exported GDS policies via Service Manag… [ranger]

Posted by "dineshkumar-yadav (via GitHub)" <gi...@apache.org>.
dineshkumar-yadav merged PR #1125:
URL: https://github.com/apache/ranger/pull/1125


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@ranger.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] RANGER-5729: Unable to import exported GDS policies via Service Manag… [ranger]

Posted by "mneethiraj (via GitHub)" <gi...@apache.org>.
mneethiraj commented on code in PR #1125:
URL: https://github.com/apache/ranger/pull/1125#discussion_r3713177950


##########
security-admin/src/main/java/org/apache/ranger/rest/ServiceREST.java:
##########
@@ -3833,24 +3839,26 @@ private List<RangerPolicy> getAllFilteredPolicyList(SearchFilter filter, HttpSer
 
         if (!CollectionUtils.isEmpty(policyLists)) {
             for (RangerPolicy policy : policyLists) {
-                if (policy != null) {
+                if (policy != null && !isGdsPolicy(policy)) {
                     //set createTime & updateTime Time as null since exported policies dont need this
                     policy.setCreateTime(null);
                     policy.setUpdateTime(null);
 
                     orderedPolicies.put(policy.getId(), policy);
                 }
             }
-            if (!orderedPolicies.isEmpty()) {
-                policyLists.clear();
 
-                policyLists.addAll(orderedPolicies.values());
-            }
+            policyLists.clear();
+            policyLists.addAll(orderedPolicies.values());
         }
 
         return policyLists;
     }
 
+    private boolean isGdsPolicy(RangerPolicy policy) {
+        return EMBEDDED_SERVICEDEF_GDS_NAME.equals(policy.getServiceType()) || ServiceDBStore.GDS_SERVICE_NAME.equals(policy.getService());

Review Comment:
   Must this condition look for service name match - `ServiceDBStore.GDS_SERVICE_NAME.equals(policy.getService())`? Why not only look for serviceType match?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@ranger.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org