Skip to content

refactor(http): decode request payload without reshaping it - #141

Open
ArnabChatterjee20k wants to merge 1 commit into
mainfrom
no-request-payload-transform
Open

refactor(http): decode request payload without reshaping it#141
ArnabChatterjee20k wants to merge 1 commit into
mainfrom
no-request-payload-transform

Conversation

@ArnabChatterjee20k

Copy link
Copy Markdown
Contributor

decodePayload previously walked the decoded body to turn objects into associative arrays while keeping empty objects as stdClass, so the request layer both decoded and reshaped the payload. Decode to the natural PHP shape instead — objects stay stdClass, lists stay arrays — which keeps {} distinct from [] without the reshape. Consumers that want an associative shape now transform explicitly at their own layer.

decodePayload previously walked the decoded body to turn objects into
associative arrays while keeping empty objects as stdClass, so the
request layer both decoded and reshaped the payload. Decode to the
natural PHP shape instead — objects stay stdClass, lists stay arrays —
which keeps {} distinct from [] without the reshape. Consumers that
want an associative shape now transform explicitly at their own layer.
@greptile-apps

greptile-apps Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR stops recursively reshaping decoded JSON objects into associative arrays while retaining the top-level parameter map expected by the request API.

  • Nested JSON objects now remain stdClass, while lists remain arrays.
  • Scalar and invalid JSON bodies continue to produce no request parameters.
  • Swoole request tests now verify natural PHP shapes, including objects nested inside lists.

Confidence Score: 5/5

The PR appears safe to merge, with the intentional payload-shape change consistently implemented and covered across the affected request paths.

The shared decoder preserves the required top-level parameter array, leaves nested JSON values in their natural PHP representations, and remains compatible with the repository’s route binding and round-trip behavior.

Important Files Changed

Filename Overview
packages/http/src/Http/Request.php Simplifies JSON decoding to preserve nested objects as stdClass while casting only the top-level object into the request parameter map; no actionable defect was found.
packages/http/tests/SwooleRequestTest.php Updates payload-shape assertions to cover nested objects and objects inside lists under the new decoding contract.

Reviews (1): Last reviewed commit: "refactor(http): decode request payload w..." | Re-trigger Greptile

@github-actions

Copy link
Copy Markdown

Benchmark results

http — Swoole modes (4 cores, 200 VUs, 20s/run)

workload mode req/s p95
ok a 15847.309389/s 28.23ms
ok b 17655.911471/s 25.32ms
io a 461.597047/s 806.27ms
io b 3344.052362/s 51.64ms
cpu a 3220.993914/s 171.43ms
cpu b 3133.097052/s 85.13ms

a = HYPERLOOP_A (process), b = HYPERLOOP_B (coroutine)

Shared CI runners — treat absolute numbers as rough, compare modes within a run. Commit c241903.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant