Skip to content

Web Builds hosted on Itch.io return 403 for invalid asset paths rather than 404 #19029

Open
@QueenOfSquiggles

Description

@QueenOfSquiggles

Bevy version

The release number or commit hash of the version you're using.

0.15.3 (appears to still affect 0.16 though)

What you did

Found the code

https://github.com/bevyengine/bevy/blob/cd67bac544a874f668c706b837c8b3093dfb9545/crates/bevy_asset/src/io/wasm.rs#L84C1-L84C58

In asset loading there are two hardcoded response codes supported. And this is where some of my knowledge may be lacking, but AFAIK 4XX responses are the server saying "Nope you can't touch that" for whatever reason. Could this be improved by accounting for any 4XX response as a file load failure?

I believe this robustness could aid newer developers from more common pitfalls. I've spent literal weeks trying to figure out why I kept getting issues on web and a primary issue was the meta check defaulting to on and Itch.io providing a 403 when bevy would expect a 404

Proposed Solution

 match resp.status() {
            200 => {
                let data = JsFuture::from(resp.array_buffer().unwrap()).await.unwrap();
                let bytes = Uint8Array::new(&data).to_vec();
                let reader = VecReader::new(bytes);
                Ok(reader)
            }
            400 ..=499  => Err(AssetReaderError::NotFound(path)),
            status => Err(AssetReaderError::HttpError(status)),
        }

Again likely a bit of naivety on my end, but I imagine all the application really cares about is whether or not the asset can be accessed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-AssetsLoad files from disk to use for things like images, models, and soundsC-BugAn unexpected or incorrect behaviorS-Needs-DesignThis issue requires design work to think about how it would best be accomplished

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions