Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: improve error message for insufficient privilege #590

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions src/storage/database/knex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -798,10 +798,7 @@ export class DBError extends StorageBackendError implements RenderableError {
static fromDBError(pgError: DatabaseError, query?: string) {
switch (pgError.code) {
case '42501':
return ERRORS.AccessDenied(
'new row violates row-level security policy',
pgError
).withMetadata({
return ERRORS.AccessDenied('Database error: insufficient privilege', pgError).withMetadata({
query,
code: pgError.code,
})
Expand Down
6 changes: 3 additions & 3 deletions src/test/object.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ describe('testing POST object via multipart upload', () => {
JSON.stringify({
statusCode: '403',
error: 'Unauthorized',
message: 'new row violates row-level security policy',
message: 'Database error: insufficient privilege',
})
)
})
Expand Down Expand Up @@ -800,7 +800,7 @@ describe('testing POST object via binary upload', () => {
JSON.stringify({
statusCode: '403',
error: 'Unauthorized',
message: 'new row violates row-level security policy',
message: 'Database error: insufficient privilege',
})
)
})
Expand Down Expand Up @@ -1672,7 +1672,7 @@ describe('testing generating signed URL for upload', () => {
JSON.stringify({
statusCode: '403',
error: 'Unauthorized',
message: 'new row violates row-level security policy',
message: 'Database error: insufficient privilege',
})
)
// Ensure that row does not exist in database.
Expand Down
46 changes: 23 additions & 23 deletions src/test/rls_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ tests:
asserts:
- operation: upload
status: 400
error: 'new row violates row-level security policy'
error: 'Database error: insufficient privilege'

- operation: upload.upsert
status: 400
message: 'new row violates row-level security policy'
message: 'Database error: insufficient privilege'

- operation: bucket.create
status: 400
error: 'new row violates row-level security policy'
error: 'Database error: insufficient privilege'

- operation: bucket.delete
status: 400
Expand Down Expand Up @@ -113,15 +113,15 @@ tests:
asserts:
- operation: upload
status: 400
error: 'new row violates row-level security policy'
error: 'Database error: insufficient privilege'

- operation: upload.upsert
status: 400
message: 'new row violates row-level security policy'
message: 'Database error: insufficient privilege'

- operation: bucket.create
status: 400
error: 'new row violates row-level security policy'
error: 'Database error: insufficient privilege'

- operation: bucket.delete
status: 400
Expand Down Expand Up @@ -199,11 +199,11 @@ tests:

- operation: upload
status: 400
error: 'new row violates row-level security policy'
error: 'Database error: insufficient privilege'

- operation: upload.upsert
status: 400
message: 'new row violates row-level security policy'
message: 'Database error: insufficient privilege'

- operation: upload
policies:
Expand Down Expand Up @@ -240,19 +240,19 @@ tests:
asserts:
- operation: bucket.create
status: 400
error: 'new row violates row-level security policy'
error: 'Database error: insufficient privilege'

- operation: bucket.delete
status: 400
error: 'Bucket not found'

- operation: upload
status: 400
error: 'new row violates row-level security policy'
error: 'Database error: insufficient privilege'

- operation: upload.upsert
status: 400
message: 'new row violates row-level security policy'
message: 'Database error: insufficient privilege'

- operation: upload
policies:
Expand Down Expand Up @@ -281,7 +281,7 @@ tests:
asserts:
- operation: bucket.create
status: 400
error: 'new row violates row-level security policy'
error: 'Database error: insufficient privilege'

- operation: bucket.delete
status: 400
Expand Down Expand Up @@ -322,15 +322,15 @@ tests:

- operation: bucket.create
status: 400
error: 'new row violates row-level security policy'
error: 'Database error: insufficient privilege'

- operation: upload
status: 400
error: 'new row violates row-level security policy'
error: 'Database error: insufficient privilege'

- operation: upload.upsert
status: 400
message: 'new row violates row-level security policy'
message: 'Database error: insufficient privilege'

- operation: upload
policies:
Expand Down Expand Up @@ -363,15 +363,15 @@ tests:

- operation: bucket.create
status: 400
error: 'new row violates row-level security policy'
error: 'Database error: insufficient privilege'

- operation: upload
status: 400
error: 'new row violates row-level security policy'
error: 'Database error: insufficient privilege'

- operation: upload.upsert
status: 400
message: 'new row violates row-level security policy'
message: 'Database error: insufficient privilege'

- operation: upload
bucketName: 'bucket_delete_test_{{runId}}'
Expand Down Expand Up @@ -406,15 +406,15 @@ tests:

- operation: bucket.create
status: 400
error: 'new row violates row-level security policy'
error: 'Database error: insufficient privilege'

- operation: upload
status: 400
error: 'new row violates row-level security policy'
error: 'Database error: insufficient privilege'

- operation: upload.upsert
status: 400
message: 'new row violates row-level security policy'
message: 'Database error: insufficient privilege'

- operation: upload
bucketName: 'bucket_to_move_{{runId}}'
Expand Down Expand Up @@ -446,7 +446,7 @@ tests:

- operation: bucket.create
status: 400
error: 'new row violates row-level security policy'
error: 'Database error: insufficient privilege'

- operation: upload
bucketName: 'bucket_{{runId}}'
Expand All @@ -457,7 +457,7 @@ tests:
useExistingBucketName: 'bucket_{{runId}}'
objectName: 'object_{{runId}}.txt'
status: 400
message: 'new row violates row-level security policy'
message: 'Database error: insufficient privilege'

- operation: upload
bucketName: 'bucket_to_copy_{{runId}}'
Expand Down
Loading