logto icon indicating copy to clipboard operation
logto copied to clipboard

feat(core,phrases): throw database error with meaningful message

Open IceHe opened this issue 2 years ago • 2 comments

Summary

Throw RequestError about DatabaseError with meaningful message

  • e.g. value too long for type character varying(128)

Testing

  • [x] UTs
image
  • Locally tested.

image

IceHe avatar Jul 29 '22 11:07 IceHe

LOG-3669 Backend: Throw database error with meaningful message

Situation:

The updating API, such asPOST /api/users and PATCH /api/users/:userId, will throw unknown error if the parameter, such as `username` and `name` (full name), exceeds the max length that is limited by the declared type `varchar(n)` of related property (max length is `n`) in the database table.

(See logto-oi/logto/packages/schemas/tables/users.sql and logto-oi/logto/packages/schemas/tables/application.sql for more details about the max lengths of the properties.)

---

Target:

  • Backend: Throw an error with a meaningful message when the property exceed its max length.

linear[bot] avatar Jul 29 '22 11:07 linear[bot]

COMPARE TO master

Total Size Diff :chart_with_downwards_trend: -73 Bytes

Diff by File
Name Diff
packages/connector-mock-mail/package.json 0 Bytes
packages/connector-mock-sms/package.json 0 Bytes
packages/core/package.json :chart_with_downwards_trend: -47 Bytes
packages/core/src/middleware/koa-slonik-error-handler.test.ts :chart_with_downwards_trend: -392 Bytes
packages/core/src/middleware/koa-slonik-error-handler.ts :chart_with_downwards_trend: -166 Bytes
packages/phrases/src/locales/en/errors.ts :chart_with_downwards_trend: -79 Bytes
packages/phrases/src/locales/zh-cn/errors.ts :chart_with_downwards_trend: -62 Bytes
pnpm-lock.yaml :chart_with_downwards_trend: -819 Bytes

github-actions[bot] avatar Jul 29 '22 11:07 github-actions[bot]

Closed. We will check and throw errors using the guard and createdGuard generated by schemas.

IceHe avatar Aug 02 '22 08:08 IceHe