Skip to content

step.request_parse: support application/x-www-form-urlencoded body parsing #257

@intel352

Description

@intel352

Current Behavior

step.request_parse with parse_body: true only supports JSON bodies. When the Content-Type is application/x-www-form-urlencoded, the step reads the body bytes via io.ReadAll() then calls json.Unmarshal(), which fails silently. As a result:

  • output["body"] is never populated — the form field data is lost
  • The body stream is consumed and unavailable for subsequent steps (e.g. step.webhook_verify)

This breaks webhook integrations that send form-encoded POST bodies, such as Twilio.

Requested Behavior

When parse_body: true is set and the Content-Type header is application/x-www-form-urlencoded, step.request_parse should:

  1. Parse the body using url.ParseQuery() instead of json.Unmarshal()
  2. Expose each form field in output["body"] as a string (first value) or []string (multiple values)
  3. Cache the raw body bytes in pc.Metadata["_raw_body"] so subsequent steps (e.g. step.webhook_verify) can still access the original payload

Example

Given a Twilio webhook POST with body:

Body=Hello&From=%2B15551234567&To=%2B15559876543&MessageSid=SM1234

After step.request_parse with parse_body: true:

steps.<name>.body.Body       = "Hello"
steps.<name>.body.From       = "+15551234567"
steps.<name>.body.To         = "+15559876543"
steps.<name>.body.MessageSid = "SM1234"

And pc.Metadata["_raw_body"] should contain the original raw bytes so step.webhook_verify (which needs to re-read the body for HMAC-SHA1 validation) can still function.

Workaround

A custom step.form_parse step that reads _raw_body from pipeline metadata and parses via url.ParseQuery().

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions