summaryrefslogtreecommitdiffhomepage
path: root/.rules/changelog/2026-03/18/02.md
blob: 1f24ea790a34c096d87ca4325561adaeb26fabb7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# Convert form-urlencoded webhook payloads to JSON

## Problem

GitHub webhooks default to `Content-Type: application/x-www-form-urlencoded`, sending the JSON payload URL-encoded under a `payload` form field. Dokploy expects `application/json` bodies, so `req.body.ref` was `undefined`, causing a `{"message":"Branch Not Match"}` error on every push event.

## Changes

### `Cargo.toml`
- Added `form_urlencoded = "1"` dependency for parsing URL-encoded form data.

### `src/main.rs`
- Added `content_type_is_form_urlencoded()` helper to detect form-urlencoded requests.
- Added `extract_json_from_form()` helper to extract the `payload` field and return raw JSON bytes.
- Clone request headers before consuming the body so Content-Type can be inspected.
- When a form-urlencoded payload is detected, extract the JSON and override the `Content-Type` header to `application/json` before forwarding to Dokploy.
- Requests already using `application/json` pass through unchanged.

### `bin/test.sh`
- Added Test 6: verifies form-urlencoded payloads with a `payload` field are forwarded correctly.