Skip to content
Merged
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
22 changes: 15 additions & 7 deletions src/internal/errors/codes.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { IcebergError } from '@storage/protocols/iceberg/catalog/errors'
import { DatabaseError } from 'pg'
import { StorageBackendError } from './storage-error'

export enum ErrorCode {
Expand Down Expand Up @@ -401,13 +402,20 @@ export const ERRORS = {
originalError: e,
}),

DatabaseSchemaMismatch: (e?: Error) =>
new StorageBackendError({
code: ErrorCode.DatabaseSchemaMismatch,
httpStatusCode: 503,
message: 'The database schema is out of sync. Please run migrations or contact support.',
originalError: e,
}),
DatabaseSchemaMismatch: (e: DatabaseError) =>
e.internalQuery && e.internalPosition // originates in trigger or RLS
? new StorageBackendError({
code: ErrorCode.DatabaseSchemaMismatch,
httpStatusCode: 503,
message: 'There is a database schema mismatch in a trigger or RLS policy: ' + e.where,
originalError: e,
})
: new StorageBackendError({
code: ErrorCode.DatabaseSchemaMismatch,
httpStatusCode: 503,
message: 'The database schema is out of sync. Please run migrations or contact support.',
originalError: e,
}),

ResourceLocked: (e?: Error) =>
new StorageBackendError({
Expand Down
4 changes: 3 additions & 1 deletion src/storage/database/knex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1145,7 +1145,9 @@ export class DBError extends StorageBackendError implements RenderableError {
switch (pgError.code) {
case '42501':
return ERRORS.AccessDenied(
'new row violates row-level security policy',
pgError.message.includes('row-level security')
? 'new row violates row-level security policy'
Comment thread
ferhatelmas marked this conversation as resolved.
: pgError.message,
pgError
).withMetadata({
query,
Expand Down