{"record":{"id":"126ef79864d9bbf3","repo":"bevyengine/bevy","slug":"failed-to-get-execute-view-query","errorCode":null,"errorMessage":"Failed to get execute view query","messagePattern":"Failed to get execute view query","errorType":"exception","errorClass":"DrawError","httpStatus":null,"severity":"error","filePath":"crates/bevy_render/src/render_phase/draw.rs","lineNumber":48,"sourceCode":"        reason = \"The parameters here are intentionally unused by the default implementation; however, putting underscores here will result in the underscores being copied by rust-analyzer's tab completion.\"\n    )]\n    fn prepare(&mut self, world: &'_ World) {}\n\n    /// Draws a [`PhaseItem`] by issuing zero or more `draw` calls via the [`TrackedRenderPass`].\n    fn draw<'w>(\n        &mut self,\n        world: &'w World,\n        pass: &mut TrackedRenderPass<'w>,\n        view: Entity,\n        item: &P,\n    ) -> Result<(), DrawError>;\n}\n\n#[derive(Error, Debug, PartialEq, Eq)]\npub enum DrawError {\n    #[error(\"Failed to execute render command {0:?}\")]\n    RenderCommandFailure(&'static str),\n    #[error(\"Failed to get execute view query\")]\n    InvalidViewQuery,\n    #[error(\"View entity not found\")]\n    ViewEntityNotFound,\n}\n\n/// Stores all [`Draw`] functions for the [`PhaseItem`] type.\n///\n/// For retrieval, the [`Draw`] functions are mapped to their respective [`TypeId`]s.\npub struct DrawFunctionsInternal<P: PhaseItem> {\n    pub draw_functions: Vec<Box<dyn Draw<P>>>,\n    pub indices: TypeIdHashMap<DrawFunctionId>,\n}\n\nimpl<P: PhaseItem> DrawFunctionsInternal<P> {\n    /// Prepares all draw function. This is called once and only once before the phase begins.\n    pub fn prepare(&mut self, world: &World) {\n        for function in &mut self.draw_functions {\n            function.prepare(world);","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/bevyengine/bevy/blob/396ca727080776bd313bb892423b7d94e03b81b4/crates/bevy_render/src/render_phase/draw.rs#L30-L66","documentation":"DrawError::InvalidViewQuery is returned by RenderCommandState::draw (draw.rs:336) when fetching the view entity with the RenderCommand's ViewQuery fails with QueryDoesNotMatch or AliasedMutability. The view entity is alive in the render world but does not satisfy the component/filter requirements the command declared, so the command cannot run.","triggerScenarios":"A RenderCommand's associated ViewQuery requires components (e.g. ExtractedView, ViewUniformOffset, or a custom view component) that the view entity in the render world lacks, or a filter that excludes that view; self.view.get_manual(world, view) returns QueryDoesNotMatch during RenderPhase::render.","commonSituations":"Custom render commands shared between view types (main camera vs shadow vs prepass views) where only some carry the required component; plugins that forget to extract their view component into the render world; adding a component to ViewQuery that is attached to the camera in the main world but never extracted.","solutions":["Make optional components Option<&T> / Option<&mut T> in the ViewQuery so views lacking them still match.","Ensure the required component is actually extracted to the render world (add it in your extract system or via RequiredComponents on the extracted view).","Do not share one command between phases whose views differ; queue a per-phase command whose ViewQuery matches that phase's views.","Handle the error by skipping the view for the frame while logging which command/view mismatched."],"exampleFix":"// before: view query requires a component only some views have\ntype ViewQuery = (&'static ExtractedView, &'static CustomViewData);\n\n// after: make it optional so non-matching views still pass the query\n// (handle None inside render())\ntype ViewQuery = (&'static ExtractedView, Option<&'static CustomViewData>);","handlingStrategy":"validation","validationCode":"// Run the same view query the command will use, before rendering:\nlet view_ok = view_query.get_manual(&render_world, view_entity).is_ok();\nif !view_ok {\n    warn!(\"view {view_entity:?} does not match ViewQuery; skipping\");\n}","typeGuard":null,"tryCatchPattern":"match render_phase.render(&mut pass, &world, view) {\n    Err(DrawError::InvalidViewQuery) => warn!(\"view query mismatch for {view:?}\"),\n    Err(other) => error!(\"{other:?}\"),\n    Ok(()) => {}\n}","preventionTips":["Make ViewQuery components Option<&T> unless every view in that phase carries them.","Extract every component your ViewQuery requires into the render world.","Do not share a single RenderCommand between view types with different component sets."],"tags":["bevy","ecs","query","view","render-command"],"backgroundTag":"query-component-mismatch","analyzedSha":"396ca727080776bd313bb892423b7d94e03b81b4","analyzedAt":"2026-08-20T16:12:39.808Z","contentChangedAt":"2026-08-20T16:12:39.808Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}