From f475d7918442230d3857e2b574644df9ede6bfc4 Mon Sep 17 00:00:00 2001
From: "Marc Burnie [AWS]" <mburnie@amazon.com>
Date: Thu, 31 Oct 2024 13:45:54 +0000
Subject: [PATCH] Fixing Status Code When Group Does Not Exist

---
 .../storage/provider/aws/security/UserAccessService.java   | 7 ++++---
 .../osdu/storage/records/TestIngestRecordNotFound.java     | 4 ++--
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/provider/storage-aws/src/main/java/org/opengroup/osdu/storage/provider/aws/security/UserAccessService.java b/provider/storage-aws/src/main/java/org/opengroup/osdu/storage/provider/aws/security/UserAccessService.java
index 03f1b1a37..6cdc23b31 100644
--- a/provider/storage-aws/src/main/java/org/opengroup/osdu/storage/provider/aws/security/UserAccessService.java
+++ b/provider/storage-aws/src/main/java/org/opengroup/osdu/storage/provider/aws/security/UserAccessService.java
@@ -37,6 +37,7 @@ import org.springframework.stereotype.Service;
 public class UserAccessService {
 
 
+    public static final String RECORD_WRITING_ERROR_REASON = "Error on writing record";
     @Inject
     private DpsHeaders dpsHeaders;
     @Inject
@@ -115,9 +116,9 @@ public class UserAccessService {
                 validateRecordAclsForServicePrincipal(records);
             } catch (InvalidACLException aclException) {
                 throw new AppException(
-                    HttpStatus.SC_FORBIDDEN,
-                    "Invalid ACL",
-                    String.format("ACL has invalid Group %s", aclException.getAcl()));
+                    HttpStatus.SC_BAD_REQUEST,
+                    RECORD_WRITING_ERROR_REASON,
+                    String.format("Could not find group \"%s\".", aclException.getAcl()));
             }
         }
     }
diff --git a/testing/storage-test-aws/src/test/java/org/opengroup/osdu/storage/records/TestIngestRecordNotFound.java b/testing/storage-test-aws/src/test/java/org/opengroup/osdu/storage/records/TestIngestRecordNotFound.java
index e5a1fb450..88bb34875 100644
--- a/testing/storage-test-aws/src/test/java/org/opengroup/osdu/storage/records/TestIngestRecordNotFound.java
+++ b/testing/storage-test-aws/src/test/java/org/opengroup/osdu/storage/records/TestIngestRecordNotFound.java
@@ -56,6 +56,6 @@ public class TestIngestRecordNotFound extends IngestRecordNotFoundTest {
 		CloseableHttpResponse response = TestUtils.send("records", "PUT", HeaderUtils.getHeaders(TenantUtils.getTenantName(), testUtils.getToken()), record, "");
         // it's a much simpler implementation to just check if the user is in the group that is being saved and if not to skip
         // per previous integration test requirements
-        TestUtils.getResult(response, HttpStatus.SC_FORBIDDEN, String.class);
+        TestUtils.getResult(response, HttpStatus.SC_BAD_REQUEST, String.class);
 	}
-}
\ No newline at end of file
+}
-- 
GitLab