Skip to content

Data (Array of Objects) Not Properly Serialized in FormData #2064

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
youssefMes opened this issue May 22, 2025 · 1 comment
Open

Data (Array of Objects) Not Properly Serialized in FormData #2064

youssefMes opened this issue May 22, 2025 · 1 comment
Labels
bug 🔥 Something isn't working prioritized 🚚 This issue has been prioritized and will be worked on soon

Comments

@youssefMes
Copy link

Description

When using fetch client to send multipart/form-data, arrays of objects included in multipart/form-data requests are not correctly serialized
for example
Example 1 (having more than 1 object):
teamMemberships: [{ userId: 'yh37dt1wfusy79zbax9tqlwi' }, { userId: 'r4vl2q0p4trr0710edspm6qr' },],

await createTeam({
    path: { accountId: 'dummyID' },
    body: {
      name: 'Team 1',
      shortName: 'T1',
      color: 'red',
      teamMemberships: [
        { userId: 'yh37dt1wfusy79zbax9tqlwi' },
        { userId: 'r4vl2q0p4trr0710edspm6qr' },
      ],
    },
  });

Will result in this body (Serialized objects inside the array but the array itself is not)

{
  name: 'Team 1',
  shortName: 'T1',
  color: 'red',
  teamMemberships: [
    '{"userId":"yh37dt1wfusy79zbax9tqlwi"}',
    '{"userId":"r4vl2q0p4trr0710edspm6qr"}'
  ]
}

Example 2 (having only one object in the array): teamMemberships: [{ userId: 'r4vl2q0p4trr0710edspm6qr' }]
Will result in this body (Serialized object but its not an array anymore)

{
  name: 'Team 1',
  shortName: 'T1',
  color: 'red',
  teamMemberships: '{"userId":"yh37dt1wfusy79zbax9tqlwi"}'
}

Expected Behaviour in these cases would be to always receive a serialized array

Reproducible example or configuration

https://stackblitz.com/edit/stackblitz-starters-tn4yru5u?file=app%2Fapi%2F%5BaccountId%5D%2Fteams%2Froute.ts

A demo can be found here, which contains openapi specs file and generated sdk, the output can be seen in the terminal directly after the project setup (logged in the api route located in app/api/[accountId]/teams/route.ts)

OpenAPI specification (optional)

Can be found in stackblitz openapi.json

System information (optional)

No response

@youssefMes youssefMes added the bug 🔥 Something isn't working label May 22, 2025
Copy link

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.

@mrlubos mrlubos added the prioritized 🚚 This issue has been prioritized and will be worked on soon label May 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🔥 Something isn't working prioritized 🚚 This issue has been prioritized and will be worked on soon
Projects
None yet
Development

No branches or pull requests

2 participants