Skip to content

Commit 07cb682

Browse files
committed
PUT/PATCH bucket: swap 403/409 to better describe S3 credentials errors
Invalid S3 credentials are better described as "forbidden" (HTTP 403). Likewise, a mismatch of S3 credentials between what's supplied in the client request and what COMS has in its database is better described as a "conflict" (HTTP 409). Supporting multiple sets of valid credentials on a bucket at any time is non-trivial (credentials may have varying levels of access), so for now, only allow one set of them at any time.
1 parent ec5db53 commit 07cb682

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

app/src/controllers/bucket.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ const controller = {
9090
log.warn(`Failure to validate bucket credentials: ${e.message}`, {
9191
function: '_validateCredentials',
9292
});
93-
throw new Problem(409, {
93+
throw new Problem(403, {
9494
detail: 'Unable to validate supplied credentials for the bucket',
9595
});
9696
}
@@ -128,7 +128,7 @@ const controller = {
128128
if (e instanceof UniqueViolationError) {
129129
// Grant permissions if credentials precisely match
130130
response = await bucketService.checkGrantPermissions(data).catch(permErr => {
131-
next(new Problem(403, { detail: permErr.message, instance: req.originalUrl }));
131+
next(new Problem(409, { detail: permErr.message, instance: req.originalUrl }));
132132
});
133133
} else {
134134
next(errorToProblem(SERVICE, e));

app/tests/unit/controllers/bucket.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ describe('createBucketChild', () => {
357357
}));
358358
});
359359

360-
it('should return a 409 when bucket can not be validated', async () => {
360+
it('should return a 403 when bucket can not be validated', async () => {
361361
const req = {
362362
body: { bucketName: 'bucketName', subKey: 'subKey' },
363363
currentUser: CURRENT_USER,
@@ -404,7 +404,7 @@ describe('createBucketChild', () => {
404404
}));
405405

406406
expect(next).toHaveBeenCalledTimes(1);
407-
expect(next).toHaveBeenCalledWith(new Problem(409, {
407+
expect(next).toHaveBeenCalledWith(new Problem(403, {
408408
detail: 'Unable to validate supplied credentials for the bucket'
409409
}));
410410
});

0 commit comments

Comments
 (0)