Skip to content

Edge cases with FormData body conversion #1585

Open
@ntjess

Description

Description

When hey-api converts a body payload into a form for multipart/form-data, nested arrays with one element lose their distinction as nested upon serialization. Instead, they look like the unnested data type. It is due to this code (and its equivalent for other backends):

value.forEach((v) => serializeFormDataPair(formData, key, v));

When only one value exists, the form has no indication to wrap the inner element as a list and instead treats it as a single list

Reproducible example or configuration

repro-heyapi.zip

  • Ensure fastapi is installed with python >=3.10 as the server (optional, only to verify the 422 unprocessible entity error)
  • Ensure npm packages are available (provided in the zip for node 22.5.1)
  • Execute ./run_frontend_backend.sh and open localhost:5173 in browser
  • Click the button and observe the POST data is incorrectly formatted (list[int] is created, not list[list[int]])

To regenerate the hey-api client api, ensure the fastapi server is running (it provides the openapi file), and run npx openapi-ts

OpenAPI specification (optional)

3.1.1

System information (optional)

macos

Activity

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

Metadata

Assignees

No one assigned

    Labels

    bug 🔥Something isn't workingneeds info ⏳Further information is required

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions