Form data submitted to Netlify function encodes spaces as a plus symbol (+) instead of %20

Full context available in this issue reported by me: Modal submission payload contains plus-separated words · Issue #1631 · slackapi/bolt-js · GitHub

I’m building a Slack Bot with BoltJS to facilitate a slash command that opens a modal UI, which admins can use to enter some information and submit to my Netlify Function. From my function handler, I can see the header 'content-type': 'application/x-www-form-urlencoded', and any multi-word sentences have their spaces encoded as + instead of %20, which is undesirable.

The BoltJS team doesn’t consider this to be an issue with the Slack API, so I’m wondering if I may have configured my handler wrong in some way. The issue occurs whether I run netlify live locally, or have my function deployed live.

Here is a snippet of my handler:

const handler: Handler = async (
  event: APIGatewayEvent
): Promise<IHandlerResponse> => {
  // the raw encoded body has + instead of %20 for spaces
  console.log(event.body)

  // this runs JSON.parse() and checks the body contents
  const payload: any = parseRequestBody(
    event.body,
    event.headers['content-type']
  )

  if (isUrlVerificationRequest(payload)) {
    return {
      statusCode: 200,
      body: payload?.challenge,
    }
  }

  // this passes the payload to BoltJS
  const slackEvent: ReceiverEvent = generateReceiverEvent(payload)
  await app.processEvent(slackEvent)

  return {
    statusCode: 200,
    body: '',
  }
}

export { handler }

Ideally, I would prefer the spaces be encoded as %20 so that I can decode them reliably. What can I do? Any help would be appreciated.

Is there a page or URL where we can test this?

As far as I’m aware, Netlify doesn’t do any special configuration in sending data. Payloads are sent as-is, so I would not expect this to happen.

Any (minimal) reproductions would also be helpful.

Thanks for your reply. I shared a reproducible project here: Modal submission payload contains plus-separated words · Issue #1631 · slackapi/bolt-js · GitHub

When serving my project locally via netify live I’ve proven that payloads are received as-is and the issue is likely not on Netlify’s end. I’ll report back once I hear from the Bolt team.

Thanks for all the experimenting and the great write-up! Please let us know if this turns out to look like us and we’ll be happy to dig in a bit further!

I was suggested by the Slack team to resolve my issue by manually replacing + with %20. Apparently intentional + symbols are already URL encoded as %2B. This doesn’t feel like a proper solution, but the workaround suits my needs. I’m confident that everything is fine on Netlify’s end.

Link to solution: Modal submission payload contains plus-separated words · Issue #1631 · slackapi/bolt-js · GitHub