-
-
Notifications
You must be signed in to change notification settings - Fork 376
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(http-error-handler): non http errors will always be handled #1117
Conversation
Thanks for putting a PR together. This proposes a breaking change, so would need to go into v5 if approved. This logic is in place to allow handling http and internal errors in separate middlewares. Additionally, this is in place to not have the default message be in english. Let me take some time to reflect on this. I agree that needing to always set it for the most common use case can get annoying depending on how you structure your code. |
I think in case of a http lambda, the http error handler is or should always be the last one. Every error handling can be done before, however if an unexpected error reaches the http error handler it should response with an 500 instead of just doing nothing. |
After some reflection and some more research, I think we can merge this into the v5 branch. I'll can update the tests, docs and change log. Thanks for putting this together. |
[![Mend Renovate logo banner](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [@middy/core](https://middy.js.org) ([source](https://togithub.com/middyjs/middy)) | [`4.7.0` -> `5.0.2`](https://renovatebot.com/diffs/npm/@middy%2fcore/4.7.0/5.0.2) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@middy%2fcore/5.0.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@middy%2fcore/5.0.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@middy%2fcore/4.7.0/5.0.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@middy%2fcore/4.7.0/5.0.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | | [@middy/error-logger](https://middy.js.org) ([source](https://togithub.com/middyjs/middy)) | [`4.7.0` -> `5.0.2`](https://renovatebot.com/diffs/npm/@middy%2ferror-logger/4.7.0/5.0.2) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@middy%2ferror-logger/5.0.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@middy%2ferror-logger/5.0.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@middy%2ferror-logger/4.7.0/5.0.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@middy%2ferror-logger/4.7.0/5.0.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | | [@middy/http-content-negotiation](https://middy.js.org) ([source](https://togithub.com/middyjs/middy)) | [`4.7.0` -> `5.0.2`](https://renovatebot.com/diffs/npm/@middy%2fhttp-content-negotiation/4.7.0/5.0.2) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@middy%2fhttp-content-negotiation/5.0.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@middy%2fhttp-content-negotiation/5.0.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@middy%2fhttp-content-negotiation/4.7.0/5.0.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@middy%2fhttp-content-negotiation/4.7.0/5.0.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | | [@middy/http-error-handler](https://middy.js.org) ([source](https://togithub.com/middyjs/middy)) | [`4.7.0` -> `5.0.2`](https://renovatebot.com/diffs/npm/@middy%2fhttp-error-handler/4.7.0/5.0.2) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@middy%2fhttp-error-handler/5.0.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@middy%2fhttp-error-handler/5.0.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@middy%2fhttp-error-handler/4.7.0/5.0.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@middy%2fhttp-error-handler/4.7.0/5.0.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | | [@middy/http-header-normalizer](https://middy.js.org) ([source](https://togithub.com/middyjs/middy)) | [`4.7.0` -> `5.0.2`](https://renovatebot.com/diffs/npm/@middy%2fhttp-header-normalizer/4.7.0/5.0.2) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@middy%2fhttp-header-normalizer/5.0.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@middy%2fhttp-header-normalizer/5.0.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@middy%2fhttp-header-normalizer/4.7.0/5.0.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@middy%2fhttp-header-normalizer/4.7.0/5.0.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | | [@middy/http-json-body-parser](https://middy.js.org) ([source](https://togithub.com/middyjs/middy)) | [`4.7.0` -> `5.0.2`](https://renovatebot.com/diffs/npm/@middy%2fhttp-json-body-parser/4.7.0/5.0.2) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@middy%2fhttp-json-body-parser/5.0.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@middy%2fhttp-json-body-parser/5.0.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@middy%2fhttp-json-body-parser/4.7.0/5.0.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@middy%2fhttp-json-body-parser/4.7.0/5.0.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | | [@middy/http-response-serializer](https://middy.js.org) ([source](https://togithub.com/middyjs/middy)) | [`4.7.0` -> `5.0.2`](https://renovatebot.com/diffs/npm/@middy%2fhttp-response-serializer/4.7.0/5.0.2) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@middy%2fhttp-response-serializer/5.0.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@middy%2fhttp-response-serializer/5.0.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@middy%2fhttp-response-serializer/4.7.0/5.0.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@middy%2fhttp-response-serializer/4.7.0/5.0.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | | [@middy/validator](https://middy.js.org) ([source](https://togithub.com/middyjs/middy)) | [`4.7.0` -> `5.0.2`](https://renovatebot.com/diffs/npm/@middy%2fvalidator/4.7.0/5.0.2) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@middy%2fvalidator/5.0.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@middy%2fvalidator/5.0.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@middy%2fvalidator/4.7.0/5.0.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@middy%2fvalidator/4.7.0/5.0.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>middyjs/middy (@​middy/core)</summary> ### [`v5.0.2`](https://togithub.com/middyjs/middy/releases/tag/5.0.2) [Compare Source](https://togithub.com/middyjs/middy/compare/5.0.1...5.0.2) ##### What's Changed - Validation error cause typo by [@​stepansib](https://togithub.com/stepansib) in [https://github.com/middyjs/middy/pull/1138](https://togithub.com/middyjs/middy/pull/1138) - Update similar typo in other files ##### New Contributors - [@​stepansib](https://togithub.com/stepansib) made their first contribution in [https://github.com/middyjs/middy/pull/1138](https://togithub.com/middyjs/middy/pull/1138) **Full Changelog**: middyjs/middy@5.0.1...5.0.2 ### [`v5.0.1`](https://togithub.com/middyjs/middy/releases/tag/5.0.1) [Compare Source](https://togithub.com/middyjs/middy/compare/5.0.0...5.0.1) #### What's Changed - ci: Add in missing types file [@​lbevilacqua](https://togithub.com/lbevilacqua) [https://github.com/middyjs/middy/issues/1136](https://togithub.com/middyjs/middy/issues/1136) - chore(website): Update website-publish.yml by [@​lmammino](https://togithub.com/lmammino) in [https://github.com/middyjs/middy/pull/1135](https://togithub.com/middyjs/middy/pull/1135) **Full Changelog**: middyjs/middy@5.0.0...5.0.1 ### [`v5.0.0`](https://togithub.com/middyjs/middy/releases/tag/5.0.0) [Compare Source](https://togithub.com/middyjs/middy/compare/4.7.0...5.0.0) For full details and upgrade guide see https://middy.js.org/docs/upgrade/4-5 #### Notable changes - Middy no longer support Common JS modules. - Deprecate Node.js v16.x. - Add support for Node.js v20.x. - Update to use TypeScript v5 along with a refactor to most packages - Update all errors to be consistent `new Error('message', { cause: { package:'@​middy/***', data:*** } })` - If using multiple `http-*-body-parsers` on the same endpoint you'll need to set `{ disableContentTypeError: true }` #### What's Changed - fix(appconfig): [#​1009](https://togithub.com/middyjs/middy/issues/1009) rewrite to not use deprecated appconfig getConfiguration command by [@​mju-spyrosoft](https://togithub.com/mju-spyrosoft) in [https://github.com/middyjs/middy/pull/1029](https://togithub.com/middyjs/middy/pull/1029) - Green CI for 5.0 by [@​lmammino](https://togithub.com/lmammino) in [https://github.com/middyjs/middy/pull/1090](https://togithub.com/middyjs/middy/pull/1090) - feat(json-body-parser): allow specifying versioned APIGW events by [@​naorpeled](https://togithub.com/naorpeled) in [https://github.com/middyjs/middy/pull/1100](https://togithub.com/middyjs/middy/pull/1100) - feat(typescript): getInternal type safety + other type improvements by [@​m-radzikowski](https://togithub.com/m-radzikowski) in [https://github.com/middyjs/middy/pull/1093](https://togithub.com/middyjs/middy/pull/1093) - Fix typo by [@​michael-k](https://togithub.com/michael-k) in [https://github.com/middyjs/middy/pull/1110](https://togithub.com/middyjs/middy/pull/1110) - docs: add Powertools idempotency + fix typo by [@​dreamorosi](https://togithub.com/dreamorosi) in [https://github.com/middyjs/middy/pull/1115](https://togithub.com/middyjs/middy/pull/1115) - fix(http-error-handler): non http errors will always be handled by [@​qoomon](https://togithub.com/qoomon) in [https://github.com/middyjs/middy/pull/1117](https://togithub.com/middyjs/middy/pull/1117) - feat: add `@iress/middy-http-path-router` to third-party middleware docs by [@​RodneyMarsh](https://togithub.com/RodneyMarsh) in [https://github.com/middyjs/middy/pull/1124](https://togithub.com/middyjs/middy/pull/1124) - fix(website): extra padding on mobile by [@​lmammino](https://togithub.com/lmammino) in [https://github.com/middyjs/middy/pull/1126](https://togithub.com/middyjs/middy/pull/1126) - Feat: improve TS docs, mention Middeware-first, Handler-last pattern by [@​lmammino](https://togithub.com/lmammino) in [https://github.com/middyjs/middy/pull/1130](https://togithub.com/middyjs/middy/pull/1130) - Update website to docusaurus3 by [@​lmammino](https://togithub.com/lmammino) in [https://github.com/middyjs/middy/pull/1129](https://togithub.com/middyjs/middy/pull/1129) - fix(middlewares/http-json-body-parser): narrow body type to string by [@​naorpeled](https://togithub.com/naorpeled) in [https://github.com/middyjs/middy/pull/1131](https://togithub.com/middyjs/middy/pull/1131) - fix: don't throw error for non http event by [@​robertbeal](https://togithub.com/robertbeal) in [https://github.com/middyjs/middy/pull/1133](https://togithub.com/middyjs/middy/pull/1133) #### New Contributors - [@​mju-spyrosoft](https://togithub.com/mju-spyrosoft) made their first contribution in [https://github.com/middyjs/middy/pull/1029](https://togithub.com/middyjs/middy/pull/1029) - [@​michael-k](https://togithub.com/michael-k) made their first contribution in [https://github.com/middyjs/middy/pull/1110](https://togithub.com/middyjs/middy/pull/1110) - [@​qoomon](https://togithub.com/qoomon) made their first contribution in [https://github.com/middyjs/middy/pull/1117](https://togithub.com/middyjs/middy/pull/1117) - [@​RodneyMarsh](https://togithub.com/RodneyMarsh) made their first contribution in [https://github.com/middyjs/middy/pull/1124](https://togithub.com/middyjs/middy/pull/1124) - [@​robertbeal](https://togithub.com/robertbeal) made their first contribution in [https://github.com/middyjs/middy/pull/1133](https://togithub.com/middyjs/middy/pull/1133) Big tanks to everyone who made this release possible! **Full Changelog**: middyjs/middy@4.7.0...5.0.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about these updates again. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/SvenKirschbaum/share.kirschbaum.cloud).
[![Mend Renovate logo banner](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [@middy/core](https://middy.js.org) ([source](https://togithub.com/middyjs/middy)) | [`4.7.0` -> `5.0.2`](https://renovatebot.com/diffs/npm/@middy%2fcore/4.7.0/5.0.2) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@middy%2fcore/5.0.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@middy%2fcore/5.0.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@middy%2fcore/4.7.0/5.0.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@middy%2fcore/4.7.0/5.0.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | | [@middy/error-logger](https://middy.js.org) ([source](https://togithub.com/middyjs/middy)) | [`4.7.0` -> `5.0.2`](https://renovatebot.com/diffs/npm/@middy%2ferror-logger/4.7.0/5.0.2) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@middy%2ferror-logger/5.0.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@middy%2ferror-logger/5.0.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@middy%2ferror-logger/4.7.0/5.0.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@middy%2ferror-logger/4.7.0/5.0.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | | [@middy/http-error-handler](https://middy.js.org) ([source](https://togithub.com/middyjs/middy)) | [`4.7.0` -> `5.0.2`](https://renovatebot.com/diffs/npm/@middy%2fhttp-error-handler/4.7.0/5.0.2) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@middy%2fhttp-error-handler/5.0.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@middy%2fhttp-error-handler/5.0.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@middy%2fhttp-error-handler/4.7.0/5.0.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@middy%2fhttp-error-handler/4.7.0/5.0.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | | [@middy/http-header-normalizer](https://middy.js.org) ([source](https://togithub.com/middyjs/middy)) | [`4.7.0` -> `5.0.2`](https://renovatebot.com/diffs/npm/@middy%2fhttp-header-normalizer/4.7.0/5.0.2) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@middy%2fhttp-header-normalizer/5.0.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@middy%2fhttp-header-normalizer/5.0.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@middy%2fhttp-header-normalizer/4.7.0/5.0.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@middy%2fhttp-header-normalizer/4.7.0/5.0.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | | [@middy/http-response-serializer](https://middy.js.org) ([source](https://togithub.com/middyjs/middy)) | [`4.7.0` -> `5.0.2`](https://renovatebot.com/diffs/npm/@middy%2fhttp-response-serializer/4.7.0/5.0.2) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@middy%2fhttp-response-serializer/5.0.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@middy%2fhttp-response-serializer/5.0.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@middy%2fhttp-response-serializer/4.7.0/5.0.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@middy%2fhttp-response-serializer/4.7.0/5.0.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>middyjs/middy (@​middy/core)</summary> ### [`v5.0.2`](https://togithub.com/middyjs/middy/releases/tag/5.0.2) [Compare Source](https://togithub.com/middyjs/middy/compare/5.0.1...5.0.2) ##### What's Changed - Validation error cause typo by [@​stepansib](https://togithub.com/stepansib) in [https://github.com/middyjs/middy/pull/1138](https://togithub.com/middyjs/middy/pull/1138) - Update similar typo in other files ##### New Contributors - [@​stepansib](https://togithub.com/stepansib) made their first contribution in [https://github.com/middyjs/middy/pull/1138](https://togithub.com/middyjs/middy/pull/1138) **Full Changelog**: middyjs/middy@5.0.1...5.0.2 ### [`v5.0.1`](https://togithub.com/middyjs/middy/releases/tag/5.0.1) [Compare Source](https://togithub.com/middyjs/middy/compare/5.0.0...5.0.1) #### What's Changed - ci: Add in missing types file [@​lbevilacqua](https://togithub.com/lbevilacqua) [https://github.com/middyjs/middy/issues/1136](https://togithub.com/middyjs/middy/issues/1136) - chore(website): Update website-publish.yml by [@​lmammino](https://togithub.com/lmammino) in [https://github.com/middyjs/middy/pull/1135](https://togithub.com/middyjs/middy/pull/1135) **Full Changelog**: middyjs/middy@5.0.0...5.0.1 ### [`v5.0.0`](https://togithub.com/middyjs/middy/releases/tag/5.0.0) [Compare Source](https://togithub.com/middyjs/middy/compare/4.7.0...5.0.0) For full details and upgrade guide see https://middy.js.org/docs/upgrade/4-5 #### Notable changes - Middy no longer support Common JS modules. - Deprecate Node.js v16.x. - Add support for Node.js v20.x. - Update to use TypeScript v5 along with a refactor to most packages - Update all errors to be consistent `new Error('message', { cause: { package:'@​middy/***', data:*** } })` - If using multiple `http-*-body-parsers` on the same endpoint you'll need to set `{ disableContentTypeError: true }` #### What's Changed - fix(appconfig): [#​1009](https://togithub.com/middyjs/middy/issues/1009) rewrite to not use deprecated appconfig getConfiguration command by [@​mju-spyrosoft](https://togithub.com/mju-spyrosoft) in [https://github.com/middyjs/middy/pull/1029](https://togithub.com/middyjs/middy/pull/1029) - Green CI for 5.0 by [@​lmammino](https://togithub.com/lmammino) in [https://github.com/middyjs/middy/pull/1090](https://togithub.com/middyjs/middy/pull/1090) - feat(json-body-parser): allow specifying versioned APIGW events by [@​naorpeled](https://togithub.com/naorpeled) in [https://github.com/middyjs/middy/pull/1100](https://togithub.com/middyjs/middy/pull/1100) - feat(typescript): getInternal type safety + other type improvements by [@​m-radzikowski](https://togithub.com/m-radzikowski) in [https://github.com/middyjs/middy/pull/1093](https://togithub.com/middyjs/middy/pull/1093) - Fix typo by [@​michael-k](https://togithub.com/michael-k) in [https://github.com/middyjs/middy/pull/1110](https://togithub.com/middyjs/middy/pull/1110) - docs: add Powertools idempotency + fix typo by [@​dreamorosi](https://togithub.com/dreamorosi) in [https://github.com/middyjs/middy/pull/1115](https://togithub.com/middyjs/middy/pull/1115) - fix(http-error-handler): non http errors will always be handled by [@​qoomon](https://togithub.com/qoomon) in [https://github.com/middyjs/middy/pull/1117](https://togithub.com/middyjs/middy/pull/1117) - feat: add `@iress/middy-http-path-router` to third-party middleware docs by [@​RodneyMarsh](https://togithub.com/RodneyMarsh) in [https://github.com/middyjs/middy/pull/1124](https://togithub.com/middyjs/middy/pull/1124) - fix(website): extra padding on mobile by [@​lmammino](https://togithub.com/lmammino) in [https://github.com/middyjs/middy/pull/1126](https://togithub.com/middyjs/middy/pull/1126) - Feat: improve TS docs, mention Middeware-first, Handler-last pattern by [@​lmammino](https://togithub.com/lmammino) in [https://github.com/middyjs/middy/pull/1130](https://togithub.com/middyjs/middy/pull/1130) - Update website to docusaurus3 by [@​lmammino](https://togithub.com/lmammino) in [https://github.com/middyjs/middy/pull/1129](https://togithub.com/middyjs/middy/pull/1129) - fix(middlewares/http-json-body-parser): narrow body type to string by [@​naorpeled](https://togithub.com/naorpeled) in [https://github.com/middyjs/middy/pull/1131](https://togithub.com/middyjs/middy/pull/1131) - fix: don't throw error for non http event by [@​robertbeal](https://togithub.com/robertbeal) in [https://github.com/middyjs/middy/pull/1133](https://togithub.com/middyjs/middy/pull/1133) #### New Contributors - [@​mju-spyrosoft](https://togithub.com/mju-spyrosoft) made their first contribution in [https://github.com/middyjs/middy/pull/1029](https://togithub.com/middyjs/middy/pull/1029) - [@​michael-k](https://togithub.com/michael-k) made their first contribution in [https://github.com/middyjs/middy/pull/1110](https://togithub.com/middyjs/middy/pull/1110) - [@​qoomon](https://togithub.com/qoomon) made their first contribution in [https://github.com/middyjs/middy/pull/1117](https://togithub.com/middyjs/middy/pull/1117) - [@​RodneyMarsh](https://togithub.com/RodneyMarsh) made their first contribution in [https://github.com/middyjs/middy/pull/1124](https://togithub.com/middyjs/middy/pull/1124) - [@​robertbeal](https://togithub.com/robertbeal) made their first contribution in [https://github.com/middyjs/middy/pull/1133](https://togithub.com/middyjs/middy/pull/1133) Big tanks to everyone who made this release possible! **Full Changelog**: middyjs/middy@4.7.0...5.0.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about these updates again. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/SvenKirschbaum/aws-utils).
[edit] Moved into its own issue We have a middy I realize that The internals of Please advise. BEFORE (using // import @[email protected]
if { userIsNotAuthorized } throw Error('Unauthorized') // AWS prescribes this EXACT pattern with Custom Authorizers
// callback("Unauthorized") // ... or this
middy.use(httpErrorHandler()) // etc
// APG CloudWatch logs (everything looks GOOD)
Gateway response type: UNAUTHORIZED with status code: 401
Gateway response body:
{
"message": "Unauthorized"
}
// Postman response
{
"message": "Unauthorized"
} AFTER (upgrade to // import @[email protected] // This is the only change
if { userIsNotAuthorized } throw Error('Unauthorized')
// I also tried `throw createError.Unauthorized()` per docs, but similar result to below
middy.use(httpErrorHandler())
// APG CloudWatch logs (BAD)
Authorizer result body before parsing:
{
"statusCode": 500,
"headers": {} // Note the lack of a `message` property, which by default APG expects for 4XX responses/templates
}
Execution failed due to configuration error: Invalid JSON in response: Unrecognized field "statusCode" , not marked as ignorable
// Postman response
{
"message": null
} AFTER (removed // import @[email protected]
if { userIsNotAuthenticated } throw Error('Unauthenticated')
// middy.use(httpErrorHandler()) // Removed this handler
// APG CloudWatch logs (kinda GOOD)
// Gateway response type: UNAUTHORIZED with status code: 401 // Weird, this line is missing in logs now
Gateway response body:
{
"message": "Unauthorized"
}
// Postman response
{
"message": "Unauthorized"
} Originally posted by @grant-d in #1117 (comment) |
http-error-handler currently does not handle non http errors if
fallbackMessage
is not set.This PR will handled all non http errors as 'Internal Server Error' even if no fallback message is configured.
I think this is a more expected behaviour of an error handler.