godotengine / godotengine/godot

Cannot set key on deserialized empty dictionary on resource from tool script after scene load

Open
#88,153 0 comments 0 reactions 0 assignees View on GitHub
bug topic:core
Dominant language
C++
Stars
117k
Forks
26.8k
PR merge metrics
PR metrics pending

Description

### Tested versions

- Reproducible in 4.2.1

### System information

Windows 10 - Godot 4.2.1 - Forward+ Vulkan

### Issue description

I have a node with a tool script which stores a resource.

The resource serializes a dictionary.

When I reload the saved scene, the resource is accessible in the node script. However I cannot set a key in the empty dictionary it contains. If the dictionary is not empty, everything works as expected.

If I re-initialize the empty dictionary with at least one key, then it works again. Re-initializing it as an empty dictionary does not work.

### Steps to reproduce

See MRP. It's very simple

### Minimal reproduction project (MRP)

[bug-report.zip](https://github.com/godotengine/godot/files/14225626/bug-report.zip)

Contributor guide

Open the contributing guide

Research direction

Download and run the linked minimal reproduction project with Godot 4.2.1 on Windows, then reload the saved scene and reproduce the failed key assignment on the empty dictionary. Start by tracing the resource serialization/deserialization path used by the tool script. Done means the reloaded resource accepts a new key in its empty dictionary without requiring a placeholder entry.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
game-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.