You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
deleting a custom color palette (one of 20) changes effects that use another custom palette #5533
I have bout 24 custom palettes and when i delete 1 from the middle like palette number 19/20, other custom color palettes does not change color according to the saved color
To Reproduce Bug
deleting custom palette does not change other custom color palettes
Expected Behavior
other custom color palettes should stay the same but does not when deleting 1 of 20
Install Method
Binary from WLED.me
What version of WLED?
0.17
Which microcontroller/board are you seeing the problem on?
well i have to go to palette option and then save each of the custom palettes on top of them, which kind of fixed the issue but is this a common bug like no saving other palettes properly ?
#!/bin/bash
# Search for custom palettes file scan related code
rg -n "palette" --type=cpp -l | head -20
rg -n "customPalette\|custom_palette\|palette.*scan\|scan.*palette\|palette.*file\|file.*palette" --type=cpp -C3 | head -100
Length of output: 801
🏁 Script executed:
#!/bin/bash
# Get issue body/title
gh issue view 5533 --repo wled/WLED --json title,body,labels,createdAt
# Look at custom palette file scanning code
cat wled00/palettes.cpp
# Also check set.cpp for palette-related code
rg -n "palette" wled00/set.cpp -A2 -B2 | head -80
Length of output: 28409
🏁 Script executed:
#!/bin/bash
# Look at the loadCustomPalettes function and any delete palette logic
rg -n "loadCustomPalettes\|deleteCustomPalette\|customPalette\|custom.*palette\|palette.*delete\|deletePalette" --type=cpp -A5 -B2 | head -200
# Also check filesystem/file scanning for palettes
rg -n "\.json\|SPIFFS\|LittleFS\|openDir\|scanDir" wled00/set.cpp -A3 -B2 | head -80
Length of output: 0
🏁 Script executed:
#!/bin/bash
# Search more broadly for custom palette loading functions
rg -n "loadCustomPalette\|customPal\|palettes.*load\|load.*palette" -C3 | head -150
# Check wled.h for palette-related declarations
rg -n "palette\|Palette" wled00/wled.h | head -60
# Check presets.cpp for palette file handling
cat wled00/presets.cpp | head -150
# Look at filesystem scan for palette json files
rg -n "p_[0-9]\|pal\|\.json" wled00/presets.cpp | head -60
Length of output: 4317
🏁 Script executed:
#!/bin/bash
# Find where loadCustomPalettes is defined
rg -rn "loadCustomPalettes\|customPalettes\|customPal" --type=cpp -C5
# Also check wled_server.cpp for palette delete handling
rg -n "delete\|Delete\|palette\|Palette" wled00/wled_server.cpp | head -60
# Check what files contain palette file operations
rg -rn "p_\d\+\.json\|palette.*json\|json.*palette\|/pal\|pal.*\.json" -C3 | head -100
Length of output: 0
🏁 Script executed:
#!/bin/bash
# Try finding the function with broader search
grep -rn "loadCustomPalettes\|customPal" wled00/ 2>/dev/null | head -50
# Check the full util.cpp since it was listed in palette-related files
grep -n "palette\|Palette\|pal" wled00/util.cpp | head -80
# Check xml.cpp for palette scanning/enumeration
grep -n "palette\|Palette\|pal\|delete\|scan" wled00/xml.cpp | head -80
Length of output: 2674
🏁 Script executed:
#!/bin/bash
# Read the loadCustomPalettes function in colors.cpp
sed -n '255,350p' wled00/colors.cpp
# Also check the palette delete handling in wled_server.cpp
sed -n '210,240p' wled00/wled_server.cpp
# Look at FX_fcn.cpp for the custom palette index logic
sed -n '225,300p' wled00/FX_fcn.cpp
sed -n '580,600p' wled00/FX_fcn.cpp
Length of output: 9570
@DedeHai — Yes, this issue is directly related to the custom palettes file scan in loadCustomPalettes() (wled00/colors.cpp, Line 262).
Here's what happens:
Root cause: Custom palettes are stored as sequentially-numbered files (/palette0.json, /palette1.json, …, /palette23.json). loadCustomPalettes() scans these files in order and pushes each valid one into the customPalettes[] vector. Custom palette IDs are assigned top-down from 255: customPalettes[0] → palette ID 255, customPalettes[1] → palette ID 254, etc.
When the user deletes /palette19.json, the file scan compacts the vector:
After deletion
File
Vector slot
Palette ID
(unchanged)
palette18.json
[18]
237
(shifted!)
palette20.json
[19]
236 ← was 235
(shifted!)
palette21.json
[20]
235 ← was 234
…
…
…
…
Every custom palette after the deleted one shifts by one slot in the vector, changing its effective palette ID. Since segments/presets store the numeric palette ID, they now silently reference the wrong palette.
The workaround the user found (re-saving each palette on top of itself) works because it re-aligns the file numbering with the stored IDs.
This is the weak point:loadCustomPalettes() compacts the vector over any file gap without updating the palette IDs saved in segment/preset state. A possible fix would be to either:
Preserve gaps in the customPalettes vector (insert a placeholder/null palette for missing files), or
Renumber all subsequent palette files when one is deleted, keeping indices contiguous, or
Update all palette references in presets/segments after a deletion.
@adamjensen61 actually this is expected behaviour, if you delete a cutom palette, they do get re-assigned numbers, changing all subsequent custom palettes.
well i have to go to palette option and then save each of the custom palettes on top of them, which kind of fixed the issue but is this a common bug like no saving other palettes properly ?
it is not a "common bug" as having more than 3 custom palettes is quite a new feature. it could use improvement for better usability, for example by inserting stubs into the vector as the rabbit sais. not sure its easily feasible without rewriting a whole bunch of palette handling code.
@adamjensen61 I fixed this by keeping the ID's of custom palettes consistent when deleting palettes. Please check if this fixes your finding, it will be in the nightly release tomorrow.
@DedeHai Btw i think if you like keep it at default color like amber by not deleting the whole palette file, that would be good coz of the missing palette number
not showing unused custom palettes was intentional to not clutter the list, they are replaced automatically when you save a new one. using names for palettes is a frequent request, however there is currently no code structure to support that and the names would need to be read from the palette files directly. not impossible to do but also not something that is doable in a few hours.
changed the title [-]Custom color palettes[/-][+]deleting a custom color palette (one of 20) changes effects that use another custom palette[/+]on Apr 28, 2026
Activity
DedeHai commentedon Apr 24, 2026
you may have hit a weak point in color delete algorithm
adam-61 commentedon Apr 24, 2026
What you mean by weak point
adam-61 commentedon Apr 24, 2026
well i have to go to palette option and then save each of the custom palettes on top of them, which kind of fixed the issue but is this a common bug like no saving other palettes properly ?
DedeHai commentedon Apr 24, 2026
@coderabbitai is the issue related to custom palettes file scan or is it unrelated?
coderabbitai commentedon Apr 24, 2026
🧩 Analysis chain
🏁 Script executed:
Length of output: 652
🏁 Script executed:
Length of output: 801
🏁 Script executed:
Length of output: 28409
🏁 Script executed:
Length of output: 0
🏁 Script executed:
Length of output: 4317
🏁 Script executed:
Length of output: 0
🏁 Script executed:
Length of output: 2674
🏁 Script executed:
Length of output: 9570
@DedeHai— Yes, this issue is directly related to the custom palettes file scan inloadCustomPalettes()(wled00/colors.cpp, Line 262).Here's what happens:
Root cause: Custom palettes are stored as sequentially-numbered files (
/palette0.json,/palette1.json, …,/palette23.json).loadCustomPalettes()scans these files in order and pushes each valid one into thecustomPalettes[]vector. Custom palette IDs are assigned top-down from 255:customPalettes[0]→ palette ID 255,customPalettes[1]→ palette ID 254, etc.When the user deletes
/palette19.json, the file scan compacts the vector:Every custom palette after the deleted one shifts by one slot in the vector, changing its effective palette ID. Since segments/presets store the numeric palette ID, they now silently reference the wrong palette.
The workaround the user found (re-saving each palette on top of itself) works because it re-aligns the file numbering with the stored IDs.
This is the weak point:
loadCustomPalettes()compacts the vector over any file gap without updating the palette IDs saved in segment/preset state. A possible fix would be to either:customPalettesvector (insert a placeholder/null palette for missing files), orDedeHai commentedon Apr 24, 2026
@adamjensen61 actually this is expected behaviour, if you delete a cutom palette, they do get re-assigned numbers, changing all subsequent custom palettes.
adam-61 commentedon Apr 25, 2026
yeh they get re-assigned but the colors dnt match with the palettes if i delete 1 from the middle, i guess i have to keep or change to another color
DedeHai commentedon Apr 25, 2026
it is not a "common bug" as having more than 3 custom palettes is quite a new feature. it could use improvement for better usability, for example by inserting stubs into the vector as the rabbit sais. not sure its easily feasible without rewriting a whole bunch of palette handling code.
DedeHai commentedon Apr 25, 2026
@adamjensen61 I fixed this by keeping the ID's of custom palettes consistent when deleting palettes. Please check if this fixes your finding, it will be in the nightly release tomorrow.
adam-61 commentedon Apr 26, 2026
@DedeHai Yeh it fixed the issue, i saved those palettes again soo few of my playlist is messed up with different colors, thanks for the fix
adam-61 commentedon Apr 26, 2026
@DedeHai Btw i think if you like keep it at default color like amber by not deleting the whole palette file, that would be good coz of the missing palette number
adam-61 commentedon Apr 26, 2026
Also you could add option for like naming/renaming custom palettes
DedeHai commentedon Apr 26, 2026
not showing unused custom palettes was intentional to not clutter the list, they are replaced automatically when you save a new one. using names for palettes is a frequent request, however there is currently no code structure to support that and the names would need to be read from the palette files directly. not impossible to do but also not something that is doable in a few hours.
[-]Custom color palettes[/-][+]deleting a custom color palette (one of 20) changes effects that use another custom palette[/+]