godotengine / godotengine/godot

Scene and Resource files invisibly override non-exported variables

Open
#98,524 6 comments 0 reactions 0 assignees View on GitHub
bug topic:editor
Dominant language
C++
Stars
117k
Forks
26.8k
PR merge metrics
PR metrics pending

Description

### Tested versions

- Reproducible in: 4.3 stable

### System information

Godot v4.3.stable - Arch Linux

### Issue description

Scene and Resource files (.tscn and .tres) can set variables that aren't marked for `@export`. This seems relatively harmless until you remove the `@export` keyword from a variable during code refactoring: every scene that overrides the variable will continue doing so _even though you can't see it in the inspector anymore._

Saving the affected scene automatically fixes the problem, so it's easy to solve by accident or if you grep/edit .tscn files in an external editor. But if you're not lucky or comfortable tinkering with Godot's files outside it, these phantom values are intractable.

### Steps to reproduce

1. Create a scene or resource with an `@export` variable in its script.
2. Set the variable in the inspector and save the scene/resource in its own file.
3. _Close the file._ Do not open and resave it after this.
4. Remove `@export` from the script.
5. Run the project with the scene or resource instantiated. Its variable will continue to be silently overwritten.

Alternatively, just append something like this to a .tscn file:
`non_exported_variable = "Incorrect value you can't see in the inspector"`

### Minimal reproduction project (MRP)

[bad_math.zip](https://github.com/user-attachments/files/17522612/bad_math.zip)

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the behavior with the linked bad_math.zip project in Godot 4.3, then inspect the saved .tscn or .tres content after removing @export. Trace how scene and resource files apply stored values to non-exported variables; done means those hidden overrides no longer persist or silently affect instantiated objects.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.