payloadcms / payloadcms/payload

JSON field with array of arrays becomes array with a single object when any other field is modified via the API

Open
#13,853 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

stale status: needs-triage
Dominant language
TypeScript
Stars
44.8k
Forks
4.2k
Avg merge
2d 21h
Merged PRs (30d)
53

Description

Describe the Bug

I have a document on Payload CMS. It has two fields on it, a select field, and a json field.

The JSON field contains an array of arrays, or more precisely [number, number][]. For example:

[[100, 200]]

I've made a small change in the list view to make it quicker to make certain changes to records. This uses the API to update it, and doesn't touch the json field.

However, whenever I use the API to touch a document, the JSON field value changes. The example above becomes:

[
  {
    "0": 100,
    "1": 200
  }
]
Link to the code that reproduces this issue

https://github.com/SethFalco/payload-cms-sandbox-2

Reproduction Steps
  1. Run the application. (It's configured to use SQLite.)
  2. Create a record for Custom Type.
    • Doesn't matter what you set for status.
    • For timestamps, you must specify an array of arrays. For example: [[100, 200]]
  3. Go to the list view.
  4. Select the drop-down, and select the option that is already current value.
  5. Now click into the record that you just modified the status for.
  6. Observe that the value of the timestamps field has changed.
Which area(s) are affected? (Select all that apply)

db-mongodb

Environment Info
Binaries:
  Node: 22.16.0
  npm: 11.6.0
  Yarn: 4.9.4
  pnpm: 10.6.5
Relevant Packages:
  payload: 3.56.0
  next: 15.4.4
  @payloadcms/email-nodemailer: 3.56.0
  @payloadcms/graphql: 3.56.0
  @payloadcms/next/utilities: 3.56.0
  @payloadcms/payload-cloud: 3.56.0
  @payloadcms/richtext-lexical: 3.56.0
  @payloadcms/translations: 3.56.0
  @payloadcms/ui/shared: 3.56.0
  react: 19.1.0
  react-dom: 19.1.0
Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP PREEMPT_DYNAMIC Debian 6.12.41-1 (2025-08-12)
  Available memory (MB): 96204
  Available CPU cores: 22

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Run the linked payload-cms-sandbox-2 reproduction with the documented SQLite setup, then trace the API update triggered from the list view and the persistence path for the JSON field. Compare the stored and returned values before and after changing the select field; done means an array of arrays such as [[100, 200]] remains unchanged when another field is updated.

Written by the indexing model from the issue text.

Assessment

Tech stack
mongodb, typescript
Domain
api, database
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.