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(cli): reject webhooks with unsupported content types #8029

Closed

Conversation

entropitor
Copy link

@entropitor entropitor commented Dec 14, 2023

If there is no actual body, the content-type doesn't matter. This way, the webhook is not started with an empty body.

To be backwards compatible, we should maybe only throw if an option on the node is enabled (maybe some workflows don't care about the body and will break if we merge this as if). WDYT?

Summary

If webhook requests come in with an unsupported content-type, the request get rejected. Before this change, the request would be accepted and the workflow would start without a body property as non of the branches would trigger. This can cause hard to understand workflow failures.

Related tickets and issues

Fixes #7700
Fixes NODE-927

Review / Merge checklist

  • PR title and summary are descriptive. Remember, the title automatically goes into the changelog. Use (no-changelog) otherwise. (conventions)
  • Docs updated or follow-up ticket created.
  • Tests included.

    A bug is not considered fixed, unless a test is added to prevent it from happening again.
    A feature is not complete without tests.

If there is no actual body, the content-type doesn't matter.
This way, the webhook is not started with an empty body.
To be backwards compatible, we should maybe only throw if an option on
the node is enabled.
Will format in next commit.

By using early return, the code is less nested and is easier to follow
@CLAassistant
Copy link

CLAassistant commented Dec 14, 2023

CLA assistant check
All committers have signed the CLA.

@n8n-assistant n8n-assistant bot added community Authored by a community member core Enhancement outside /nodes-base and /editor-ui labels Dec 14, 2023
Copy link
Member

@netroy netroy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this @entropitor, but we recently changed Webhook nodes to automatically create binary-data when the content-type is missing or invalid.
In scenarios like this, we expect the end user to use a Convert to/from binary data to parse the payload.

@netroy netroy closed this Dec 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community Authored by a community member core Enhancement outside /nodes-base and /editor-ui
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Missing Content-Type header makes webhook ignore body
3 participants