-
Notifications
You must be signed in to change notification settings - Fork 3.1k
fix: tighten up error visibility handling #14606
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
Conversation
| return ( | ||
| <tr | ||
| className={`row-${rowIndex + 1}`} | ||
| data-id={row.id} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just adding data-id for simpler e2e testing. Rest is identical
| hooks: { | ||
| beforeDelete: [ | ||
| ({ id }) => { | ||
| throw new APIError(`Test error: cannot delete document with ID ${id}`, 401) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This error will be shown
| hooks: { | ||
| beforeDelete: [ | ||
| ({ id }) => { | ||
| throw new Error(`Test error: cannot delete document with ID ${id}`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This error will not be shown
📦 esbuild Bundle Analysis for payloadThis analysis was generated by esbuild-bundle-analyzer. 🤖
Largest pathsThese visualization shows top 20 largest paths in the bundle.Meta file: packages/next/meta_index.json, Out file: esbuild/index.js
Meta file: packages/payload/meta_index.json, Out file: esbuild/index.js
Meta file: packages/payload/meta_shared.json, Out file: esbuild/exports/shared.js
Meta file: packages/richtext-lexical/meta_client.json, Out file: esbuild/exports/client_optimized/index.js
Meta file: packages/ui/meta_client.json, Out file: esbuild/exports/client_optimized/index.js
Meta file: packages/ui/meta_shared.json, Out file: esbuild/exports/shared_optimized/index.js
DetailsNext to the size is how much the size has increased or decreased compared with the base branch of this PR.
|
|
🚀 This is included in version v3.65.0 |
Fixes #14377
Non-public errors were returned from delete and update endpoints
Previously, non-public errors (
500errors, or errors withoutisPublic: trueandstatus) were returned from the delete and update endpoint. For security reason, this PR excludes the error messages from the response.This aligns bulk endpoints with others (e.g., deleteByID) that already gate error details through
routeError.ts.Loosen up isPublic check when throwing API error
APIErrornow infersisPublicfrom the status code unless explicitly provided:isPublicdefaults totrue.isPublicdefaults tofalse.You can still override by passing a boolean
isPublicexplicitly. Previously, the only way to mark the error as public was:throw new APIError('error message', 401, null ,false)which feels unnecessary explicit.
Now, you can do this:
throw new APIError('error message', 401)which previously resulted in
isPublic: falseand now results inisPublic: true.Stricter error check in routeError
routeErrornow usesisErrorPublic(err, config)to decide whether to expose the error message. Compared to the old condition (!config.debug && !err.isPublic && status === 500), this is a bit stricter and easier to understand. Errors withisPublic === falseare now hidden even for non-500 statuses (previously they were shown).