godotengine / godotengine/godot
`GLTFDocument.write_to_filesystem` squashes file IO errors into single `FAILED` error on Linux
- Dominant language
- C++
- Stars
- 117k
- Forks
- 26.8k
- PR merge metrics
- PR metrics pending
Description
### Tested versions
- Reproducible in Godot v4.6.2.stable.mono (001aa128b)
### System information
Godot v4.6.2.stable.mono (001aa128b) - Arch Linux #1 ZEN SMP PREEMPT_DYNAMIC Fri, 01 May 2026 16:30:13 +0000 on Wayland - Wayland display driver, Multi-window, 2 monitors - OpenGL 3 (Compatibility) - NVIDIA GeForce RTX 4060 Ti (nvidia; 595.71.05) - AMD Ryzen 7 5700X3D 8-Core Processor (16 threads) - 78.44 GiB memory
### Issue description
`GLTFDocument.write_to_filesystem` returns a generic `FAILED` error instead of the actual IO error that prevented writing. The farthest I've managed to track it down is to
https://github.com/godotengine/godot/blob/e880d6bbfb74479376a0cba9b106ac0c39b4cfe4/modules/gltf/gltf_document.cpp#L6675
The context of this line is below, but I'm not sure where the `FAILED` error code is actually coming from, since `_encode_bundle_bins` doesn't seem to return a `FAILED` ever, nor does `FileAccess::open` which it calls
https://github.com/godotengine/godot/blob/e880d6bbfb74479376a0cba9b106ac0c39b4cfe4/modules/gltf/gltf_document.cpp#L6675-L6682
### Steps to reproduce
Create a `gltf` file owned by root in your home directory
`sudo touch ~/testfile.gltf`
Then run the below in a copy of Godot running as a normal user
```gdscript
var doc := GLTFDocument.new()
var state := GLTFState.new()
var err := doc.write_to_filesystem(state, "~/testfile.gltf")
print("Error was %s" % error_string(err)) # Should print 'Failed'
```
### Minimal reproduction project (MRP)
N/A
Contributor guide
Research direction
Start in modules/gltf/gltf_document.cpp around lines 6675-6682, then trace write_to_filesystem into _encode_bundle_bins and FileAccess::open. Reproduce the root-owned-file case and compare the returned error with the underlying file I/O failure. Done means write_to_filesystem exposes the actual I/O error instead of a generic FAILED result.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, linux
- Domain
- game-dev, operating-systems
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100