SIGN IN SIGN UP
bevyengine / bevy UNCLAIMED

A refreshingly simple data-driven game engine built in Rust

0 0 0 Rust

Return/log an error when attempting to load an empty asset path. (#23654)

# Objective

- Partially addresses
https://discord.com/channels/691052431525675048/749332104487108618/1489425547598762095
- Currently BSN will attempt to load a string whenever a handle is seen.
Unfortunately, BSN treats nothing to mean the empty string. The asset
system then tries to load the empty string and returns various unhelpful
error messages depending on your OS.
- This doesn't totally fix the issue - BSN should probably not be
loading these paths at all. But more generally the asset system should
just ignore empty paths entirely since it should never load a meaningful
path.

## Solution

- In every load variant, add a check for the empty path and log an error
or return an error in that case. We also return a default handle in that
case (where necessary).
- Intentionally don't handle `load_folder`. You could theoretically want
to load the root folder!

To address some alternative implementations:
- There isn't a common loading API that all roads lead to! Each one is a
little different, so we need to handle them in each case. We should
investigate collapsing some of these though.
- `AssetPath` still needs to be allowed to parse an empty path, since
for stuff like joining asset paths, that needs to support cases like
"only a subasset label", or "joining the empty path with some subdir
path".

## Testing

- Added a test to test all the load variants on `AssetServer`.
A
andriyDev committed
ef69ba45b1404c08f31514c210e72fbc19a41314
Parent: f865af1
Committed by GitHub <noreply@github.com> on 4/5/2026, 4:40:15 PM