{"record":{"id":"d12f67ae62f7891d","repo":"bevyengine/bevy","slug":"failed-to-decode-base64-mesh-data","errorCode":null,"errorMessage":"failed to decode base64 mesh data","messagePattern":"failed to decode base64 mesh data","errorType":"exception","errorClass":"GltfError","httpStatus":null,"severity":"error","filePath":"crates/bevy_gltf/src/loader/mod.rs","lineNumber":99,"sourceCode":"pub const MAX_JOINTS: usize = 256;\n\n/// An error that occurs when loading a glTF file.\n#[derive(Error, Debug)]\npub enum GltfError {\n    /// Unsupported primitive mode.\n    #[error(\"unsupported primitive mode\")]\n    UnsupportedPrimitive {\n        /// The primitive mode.\n        mode: Mode,\n    },\n    /// Invalid glTF file.\n    #[error(\"invalid glTF file: {0}\")]\n    Gltf(#[from] gltf::Error),\n    /// Binary blob is missing.\n    #[error(\"binary blob is missing\")]\n    MissingBlob,\n    /// Decoding the base64 mesh data failed.\n    #[error(\"failed to decode base64 mesh data\")]\n    Base64Decode(#[from] base64::DecodeError),\n    /// Unsupported buffer format.\n    #[error(\"unsupported buffer format\")]\n    BufferFormatUnsupported,\n    /// The buffer URI was unable to be resolved with respect to the asset path.\n    #[error(\"invalid buffer uri: {0}. asset path error={1}\")]\n    InvalidBufferUri(String, ParseAssetPathError),\n    /// Invalid image mime type.\n    #[error(\"invalid image mime type: {0}\")]\n    #[from(ignore)]\n    InvalidImageMimeType(String),\n    /// Error when loading a texture. Might be due to a disabled image file format feature.\n    #[error(\"You may need to add the feature for the file format: {0}\")]\n    ImageError(#[from] TextureError),\n    /// The image URI was unable to be resolved with respect to the asset path.\n    #[error(\"invalid image uri: {0}. asset path error={1}\")]\n    InvalidImageUri(String, ParseAssetPathError),\n    /// Failed to read bytes from an asset path.","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/bevyengine/bevy/blob/396ca727080776bd313bb892423b7d94e03b81b4/crates/bevy_gltf/src/loader/mod.rs#L81-L117","documentation":"GltfError::Base64Decode (#[from] base64::DecodeError) comes from DataUri::decode (loader/mod.rs:1989-1995) when a buffer or image embedded as a \"data:...;base64,\" URI cannot be decoded. The decoder used is base64::engine::general_purpose::STANDARD, so the payload must use the standard alphabet (+, /) with correct padding and no whitespace.","triggerScenarios":"A buffer/image data URI containing URL-safe base64 ('-' or '_'), missing '=' padding, embedded newlines/spaces, or a truncated payload; the '?' at mod.rs:1939 (buffers) and mod.rs:1247 (images) propagates the DecodeError.","commonSituations":"Models produced by web tooling that emits URL-safe base64; minifiers stripping padding; copy-paste truncation of very long data URIs; hand-embedding meshes as data URIs.","solutions":["Re-encode the payload with standard base64 (padding on): `base64 -w0 file.bin` then rebuild the URI.","Prefer moving large buffers out of data URIs into an external .bin or GLB (also smaller in memory).","Verify the segment after the comma decodes: `echo <payload> | base64 -d > /dev/null`."],"exampleFix":"// (before) URL-safe alphabet, no padding\n\"uri\": \"data:application/octet-stream;base64,a-b_cd\"\n// (after) standard alphabet + padding\n\"uri\": \"data:application/octet-stream;base64,a+b/cd==\"","handlingStrategy":"validation","validationCode":"fn data_uris_decode(json: &serde_json::Value) -> Result<(), String> {\n    use base64::Engine;\n    for uri in json[\"buffers\"].as_array().unwrap_or(&vec![]).iter()\n        .filter_map(|b| b[\"uri\"].as_str())\n        .filter(|u| u.starts_with(\"data:\")) {\n        let payload = uri.split(',').nth(1).unwrap_or(\"\");\n        base64::engine::general_purpose::STANDARD\n            .decode(payload)\n            .map_err(|e| format!(\"bad base64 buffer: {e}\"))?;\n    }\n    Ok(())\n}","typeGuard":null,"tryCatchPattern":"match err {\n    GltfError::Base64Decode(e) => {\n        error!(\"embedded data URI is not standard base64: {e}\");\n    }\n    other => return Err(other.into()),\n}","preventionTips":["Generate data URIs with standard base64 and padding.","Avoid embedding large buffers as data URIs at all.","Automated check: decode every data: uri during asset import."],"tags":["gltf","base64","data-uri","buffer","bevy"],"backgroundTag":"base64-decode-failed","analyzedSha":"396ca727080776bd313bb892423b7d94e03b81b4","analyzedAt":"2026-08-20T16:12:39.808Z","contentChangedAt":"2026-08-20T16:12:39.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}