jxyz
August 26, 2026, 1:36pm
1
Describe the problem/error/question
sorting arrays in “Edit Fields” node returns “null” after upgrade to n8n version 2.36.7, it should return the sorted array
Edit Fields (Set) node version 3.4 (Latest version: 3.5)
it works in version 2.27.4
What is the error message (if any)?
Please share your workflow
Share the output returned by the last node
[
{
“sorted”: null
}
]
Information on your n8n setup
n8n version: 2.36.7
Database (default: SQLite): postgress
n8n EXECUTIONS_PROCESS setting (default: own, main):
Running n8n via (Docker, npm, n8n cloud, desktop app): docker
Operating system: ubuntu
n8n
August 26, 2026, 1:37pm
2
Hey @jxyz , while you wait for a response, here are some things that might help:
Suggested resources
Automatically matched to your question.
Docs:
Forum:
@hubschrauber , @nguyenthieutoan , @achamm - you’ve helped with similar issues before, can you take a look?
Automatically suggested by n8n’s community bot. It’s a pilot - please share feedback here .
Lopez
August 26, 2026, 1:42pm
3
Hi @jxyz
Try this, this is working
Hi @jxyz
sort() is the only thing in that expression that mutates its receiver instead of returning a new array, and mutating $json in place from an expression is the most probable cause of the null. Sort a copy:
{{ [...$json.arr].sort((a, b) => b - a) }}
If the copy returns [3, 2, 1] while the original still returns null, the break is in mutating the item data rather than in sort() itself, which is worth a bug report since the docs still show that exact compare function.
Hovec
August 26, 2026, 1:57pm
5
Before you go down the sort() mutation rabbit hole - check the Type dropdown on that “sorted” field first. Edit Fields v3 has this per-field type selector (String/Number/Array/Object) that the old Set node didn’t have. If it’s set to anything other than Array, n8n tries to force the result into that type and just goes null instead of throwing an error. Preview still looks fine because it skips that coercion step.
Hey @jxyz , both worth ruling out, but I don’t think either is it. I rebuilt your setup on 3.4 and 3.5: sorting in place returns the sorted array fine on both, and a mismatched Type gives you a coerced string rather than null. The only thing that produces exactly {“sorted”: null} is the expression resolving to undefined while the field type is Array.
So sort() isn’t what broke, the reference is. Drop the .sort() and output the raw path on its own, still typed Array. If that comes back null too, your array isn’t where it was on 2.27.4 and the real change is upstream of this node rather than in the sort.
HI !
Pretty basic flow as I’m new to n8n. I have n8n connected to ComfyUI to generate images. This all works. After ComfyUI is complete (http://server/history → status.complete=True, I need to get the binary file image (png).
THE ISSUE – I’m using an Edit Fields Node to search through the JSON tree looking for a specific key-value pair. The Edit Fields Node picks up the value correctly in the preview, but does not output anything when tested.
THANKS !!
Information on your n8n setup
n8n …
jxyz
August 26, 2026, 2:50pm
7
@Anshul_Namdev Thanks, that workaround works, I also found a bug report related to this:
opened 07:13PM - 18 Aug 26 UTC
team:cats
status:in-linear
status:team-assigned
### Bug Description
After upgrading n8n from **2.34.5 to 2.35.3**, several Java… Script Array methods called directly on arrays from `$json` now evaluate to `null` in an **Edit Fields (Set)** node.
The affected methods I have reproduced are:
```
{{ $json.data.sort() }}
{{ $json.data.splice(0, 2) }}
{{ $json.data.fill("X", 0, 2) }}
{{ $json.data.copyWithin(0, 2, 4) }}
```
Each of these returns: `null`
This did not occur on n8n **2.34.5**.
As a workaround, creating a copy of the array before calling the method works. For example: `{{ [...$json.data].sort() }}` returns the expected sorted array.
Interestingly, not all mutating Array methods are affected. For example: `{{ $json.data.reverse() }}` still works.
Non-mutating operations I tested also work correctly:
```
{{ $json.data.slice().sort() }}
{{ $json.data.filter(x => x.startsWith("B")) }}
{{ $json.data.map(x => x.toUpperCase()) }}
{{ $json.data.includes("Apple") }}
```
<img width="1203" height="773" alt="Image" src="https://github.com/user-attachments/assets/09d40c70-bba6-49a3-a994-70ff2c704675" />
### To Reproduce
Use input data such as:
```
{
"data": [
"Mango",
"Apple",
"Kiwi",
"Orange",
"Blueberry",
"Banana",
"Peach",
"Grape",
"Pineapple",
"Strawberry"
]
}
```
In an **Edit Fields (Set)** node, create fields using the expressions below.
### Returns `null`
```
{{ $json.data.sort() }}
{{ $json.data.splice(0, 2) }}
{{ $json.data.fill("X", 0, 2) }}
{{ $json.data.copyWithin(0, 2, 4) }}
```
### Works correctly
```
{{ $json.data.reverse() }}
{{ [...$json.data].sort() }}
{{ $json.data.slice().sort() }}
{{ $json.data.filter(x => x.startsWith("B")) }}
{{ $json.data.map(x => x.toUpperCase()) }}
{{ $json.data.includes("Apple") }}
```
### Expected behavior
These expressions should return the normal JavaScript result instead of silently evaluating to `null`.
For example: `{{ $json.data.sort() }}` should return the sorted array.
If direct mutation of `$json` input arrays is now intentionally unsupported, I would expect an explicit error or documentation rather than `null`.
### Debug Info
# Debug info
## core
- n8nVersion: 2.35.3
- platform: docker (self-hosted)
- nodeJsVersion: 24.18.1
- nodeEnv: production
- database: sqlite
- executionMode: regular
- concurrency: -1
- license: enterprise (production)
- consumerId: 67e05c1d-adc1-402f-9d4c-950cdf785d0f
## storage
- success: all
- error: all
- progress: false
- manual: true
- binaryMode: filesystem
## pruning
- enabled: true
- maxAge: 336 hours
- maxCount: 10000 executions
## client
- userAgent: mozilla/5.0 (windows nt 10.0; win64; x64) applewebkit/537.36 (khtml, like gecko) chrome/151.0.0.0 safari/537.36
- isTouchDevice: false
## cluster
- instanceCount: 1
- versions: 2.35.3
- instances:
- instanceKey: 68114a6b-c349-4c21-8441-f70f10912a14, hostId: main-leyden-n8n, instanceType: main, instanceRole: leader, version: 2.35.3
- checks:
- check: hostid-clash, status: succeeded, warnings: -
- check: lifecycle, status: succeeded, warnings: -
- check: split-brain, status: succeeded, warnings: -
- check: version-mismatch, status: succeeded, warnings: -
Generated at: 2026-08-18T19:05:00.953Z
### Operating System
Ubuntu 24 (Docker Host)
### n8n Version
2.35.3
### Node.js Version
24.18.1
### Database
SQLite (default)
### Execution mode
main (default)
### Hosting
self hosted
@jxyz glad it helped, can you consider marking that as a solution