OpenFn / lightning

OpenFn/Lightning ⚡️ is the newest version of the OpenFn DPG and provides a web UI to visually manage complex workflow automation projects.
https://openfn.github.io/lightning/
GNU Lesser General Public License v3.0
115 stars 31 forks source link

Reject unsupported content-types on webhooks #2186

Closed stuartc closed 2 weeks ago

stuartc commented 2 weeks ago

Validation Steps

  1. Run your local server
  2. Get a web hook url for any workflow
  3. Run a curl command:
curl \
 -X POST \
 -H "Accept: */*" \
 -H "Accept-Encoding: gzip, deflate" \
 -H "Content-Length: 4834" \
 -H "Content-Type: text/xml" \
 $WEBHOOK_URL

You should see: {"error":"Unsupported Media Type"} as the response.

Notes for the reviewer

Users that send data without a supported mime type cause exceptions to be raised because the controller tries to encode the request body (which is Unfetched).

Instead of throwing an exception, we should return a 415 error.

Related issue

Fixes #2180

Review checklist

codecov[bot] commented 2 weeks ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 89.70%. Comparing base (ec9e9cd) to head (1b01055).

:exclamation: Current head 1b01055 differs from pull request most recent head c390e3d

Please upload reports for the commit c390e3d to get more accurate results.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #2186 +/- ## ======================================= Coverage 89.69% 89.70% ======================================= Files 275 275 Lines 9036 9039 +3 ======================================= + Hits 8105 8108 +3 Misses 931 931 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.