{"record":{"id":"d6906c1cbf6ec363","repo":"bevyengine/bevy","slug":"each-assetid-should-have-a-corresponding-asset","errorCode":null,"errorMessage":"Each AssetId should have a corresponding asset","messagePattern":"Each AssetId should have a corresponding asset","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"crates/bevy_text/src/font.rs","lineNumber":77,"sourceCode":"    let new_asset_ids: Vec<_> = if font_removed {\n        // If any font asset has been removed, clear the font collection and queue the remaining fonts to be reinserted into the collection.\n        font_cx.collection.clear();\n        loaded_fonts.clear();\n        loaded_fonts.extend(fonts.ids());\n        loaded_fonts.iter().copied().collect()\n    } else {\n        fonts.ids().filter(|id| loaded_fonts.insert(*id)).collect()\n    };\n\n    if new_asset_ids.is_empty() && !font_removed {\n        return;\n    }\n\n    let mut new_family_ids = Vec::new();\n    for asset_id in &new_asset_ids {\n        let font = fonts\n            .get_mut_untracked(*asset_id)\n            .expect(\"Each AssetId should have a corresponding asset\");\n\n        font.alias = format!(\"asset_id:{asset_id:?}\");\n\n        // Each font is registered twice in Parley's FontContext collection, once under its embedded family name,\n        // and once under an alias generated from the asset id.\n        // This to allow look ups by the embedded family name while also ensuring that font asset handles\n        // accurately resolve to the correct font asset.\n        new_family_ids.extend(\n            font_cx\n                .collection\n                .register_fonts(font.data.clone(), None)\n                .iter()\n                .map(|(family_id, _)| *family_id),\n        );\n\n        font_cx.collection.register_fonts(\n            font.data.clone(),\n            Some(FontInfoOverride {","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/bevyengine/bevy/blob/4805ca792c3e94eef07afd6fa9a2712f388c9a67/crates/bevy_text/src/font.rs#L59-L95","documentation":"An expect() panic in the font-registration system (crates/bevy_text/src/font.rs): for every id returned by Assets<Font>::ids() that has not been registered yet, the code calls fonts.get_mut_untracked(id).expect(\"Each AssetId should have a corresponding asset\"). ids() only yields ids of stored assets, so the asset vanishing between enumeration and access violates an internal invariant - this is a Bevy-side bug, not normal error handling.","triggerScenarios":"Requires Assets<Font> to be mutated (entries removed) while the registration system iterates ids: manually/re-entrantly running the system, an asset plugin removing fonts from another thread mid-frame, or an ecs/assets regression. Ordinary apps cannot trigger it through public APIs.","commonSituations":"Custom schedulers that run systems manually inside other systems, exotic asset sources, or version regressions after Bevy upgrades. If you see it, it is almost always worth an upstream issue with the backtrace.","solutions":["Update Bevy; check the issue tracker for font registration / get_mut_untracked panics","Audit custom code that removes Font assets or invokes the registration system outside the normal schedule","Reproduce with a minimal app and file a Bevy issue including the panic backtrace and any asset manipulation you perform"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// If you write similar asset-iteration code, avoid expect:\nif let Some(font) = fonts.get_mut_untracked(*asset_id) {\n    font.alias = format!(\"asset_id:{asset_id:?}\");\n    // ...\n} else {\n    warn!(\"font asset {asset_id:?} vanished before registration\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run systems through the normal schedule only; no manual/re-entrant invocation","Do not remove Font assets from custom asset hooks mid-frame","If it fires, capture the backtrace and file a Bevy issue"],"tags":["rust","bevy","text","font","panic","assets","internal-invariant"],"backgroundTag":"asset-not-found","analyzedSha":"4805ca792c3e94eef07afd6fa9a2712f388c9a67","analyzedAt":"2026-08-20T16:12:39.808Z","contentChangedAt":"2026-08-20T16:12:39.808Z","schemaVersion":2},"datasetVersion":"2026-09-09T01:17:15.007Z"}