Skip to content
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: don't throw errors in http-event-normalizer #1132

Closed

Conversation

robertbeal
Copy link
Contributor

What does this implement/fix? Explain your changes.

A PR to propose changing the behaviour of the http-event-normalizer (more as a discussion point that formal PR)

Currently, the http-event-normalizer middleware will throw an error if the HTTP version cannot be established. For example if HTTP Method is missing from the event.

  • (discussion point) should the middleware care? Or care enough to throw an error which breaks the code flow. My argument is that it's designed to ensure objects are instantiated/normalised, and not to police the HTTP validity of an event object.
  • It differs in behaviour (inconsistency) from the http-header-normalizer which does not throw an error if the HTTP version cannot be figured out. This PR would make the behaviour more consistent.

Impact:

It is a breaking change as the behaviour of the middleware will be different

Does this close any currently open issues?

No

Any relevant logs, error output, etc?

N/A

Environment:

  • Node.js: 18

Any other comments?

Todo List:

  • Feature/Fix fully implemented
  • Amended tests
    • Unit tests
    • Benchmark tests (if applicable)
  • Updated relevant documentation
  • Updated relevant examples

mju-spyrosoft and others added 30 commits March 13, 2023 02:01
…ws-error-when-fetching-feature-flag-configuration

fix(appconfig): middyjs#1009 rewrite to not use deprecated appconfig getConfiguration command
# Conflicts:
#	lerna.json
#	package-lock.json
#	package.json
#	packages/appconfig/package.json
#	packages/cloudwatch-metrics/package-lock.json
#	packages/cloudwatch-metrics/package.json
#	packages/core/index.js
#	packages/core/package-lock.json
#	packages/core/package.json
#	packages/do-not-wait-for-empty-event-loop/package-lock.json
#	packages/do-not-wait-for-empty-event-loop/package.json
#	packages/dynamodb/package-lock.json
#	packages/dynamodb/package.json
#	packages/error-logger/package-lock.json
#	packages/error-logger/package.json
#	packages/event-normalizer/package-lock.json
#	packages/event-normalizer/package.json
#	packages/http-content-encoding/package-lock.json
#	packages/http-content-encoding/package.json
#	packages/http-content-negotiation/package-lock.json
#	packages/http-content-negotiation/package.json
#	packages/http-cors/package-lock.json
#	packages/http-cors/package.json
#	packages/http-error-handler/package-lock.json
#	packages/http-error-handler/package.json
#	packages/http-event-normalizer/package-lock.json
#	packages/http-event-normalizer/package.json
#	packages/http-header-normalizer/package-lock.json
#	packages/http-header-normalizer/package.json
#	packages/http-json-body-parser/package-lock.json
#	packages/http-json-body-parser/package.json
#	packages/http-multipart-body-parser/package-lock.json
#	packages/http-multipart-body-parser/package.json
#	packages/http-partial-response/package-lock.json
#	packages/http-partial-response/package.json
#	packages/http-response-serializer/package-lock.json
#	packages/http-response-serializer/package.json
#	packages/http-router/package-lock.json
#	packages/http-router/package.json
#	packages/http-security-headers/package-lock.json
#	packages/http-security-headers/package.json
#	packages/http-urlencode-body-parser/package-lock.json
#	packages/http-urlencode-body-parser/package.json
#	packages/http-urlencode-path-parser/package-lock.json
#	packages/http-urlencode-path-parser/package.json
#	packages/input-output-logger/package-lock.json
#	packages/input-output-logger/package.json
#	packages/rds-signer/package-lock.json
#	packages/rds-signer/package.json
#	packages/s3-object-response/package-lock.json
#	packages/s3-object-response/package.json
#	packages/s3/package-lock.json
#	packages/s3/package.json
#	packages/secrets-manager/package-lock.json
#	packages/secrets-manager/package.json
#	packages/service-discovery/package-lock.json
#	packages/service-discovery/package.json
#	packages/sqs-partial-batch-failure/package-lock.json
#	packages/sqs-partial-batch-failure/package.json
#	packages/ssm/package-lock.json
#	packages/ssm/package.json
#	packages/sts/package-lock.json
#	packages/sts/package.json
#	packages/util/package-lock.json
#	packages/util/package.json
#	packages/validator/package-lock.json
#	packages/validator/package.json
#	packages/warmup/package-lock.json
#	packages/warmup/package.json
#	packages/ws-json-body-parser/package-lock.json
#	packages/ws-json-body-parser/package.json
#	packages/ws-response/package-lock.json
#	packages/ws-response/package.json
#	packages/ws-router/package-lock.json
#	packages/ws-router/package.json
@robertbeal
Copy link
Contributor Author

Just had a thought, I could amend the middleware to be configurable, as to whether it throws an error or not. That would maintain compatibility..

@willfarrell
Copy link
Member

willfarrell commented Nov 14, 2023

Thanks for the PR and good point. It should be up to the validator to throw that error. We're just about to release v5, so your timing is perfect. If you can update it be against the release/5.0 branch, I can get it merged in before it releases (any day now, waiting for the new runtime to release).

@robertbeal
Copy link
Contributor Author

robertbeal commented Nov 15, 2023

Thanks for the prompt response. I've rebased it off release/5.0 (hope I got the upstream/fetch/rebase right). Actually not sure I did - just looking

@robertbeal
Copy link
Contributor Author

Will re-do with a cleaner PR git log

@robertbeal robertbeal closed this Nov 15, 2023
@robertbeal robertbeal deleted the http-event-normalizer-without-errors branch November 15, 2023 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

7 participants