diff --git a/packages/backend/src/misc/is-duplicate-key-value-error.ts b/packages/backend/src/misc/is-duplicate-key-value-error.ts index 04ff191e4133..f5343d187cbd 100644 --- a/packages/backend/src/misc/is-duplicate-key-value-error.ts +++ b/packages/backend/src/misc/is-duplicate-key-value-error.ts @@ -1,3 +1,5 @@ +import { QueryFailedError } from 'typeorm'; + export function isDuplicateKeyValueError(e: unknown | Error): boolean { - return (e as any).message && (e as Error).message.startsWith('duplicate key value'); + return e instanceof QueryFailedError && e.driverError.code === '23505'; }