{"record":{"id":"6fe2e2845b79811b","repo":"leptos-rs/leptos","slug":"a-was-not-present","errorCode":null,"errorMessage":"A was not present","messagePattern":"A was not present","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"tachys/src/view/either.rs","lineNumber":720,"sourceCode":"    fn into_owned(self) -> Self::Owned {\n        EitherKeepAlive {\n            a: self.a.map(|a| a.into_owned()),\n            b: self.b.map(|b| b.into_owned()),\n            show_b: self.show_b,\n        }\n    }\n}\n\nimpl<A, B> Mountable for EitherKeepAliveState<A, B>\nwhere\n    A: Mountable,\n    B: Mountable,\n{\n    fn unmount(&mut self) {\n        if self.showing_b {\n            self.b.as_mut().expect(\"B was not present\").unmount();\n        } else {\n            self.a.as_mut().expect(\"A was not present\").unmount();\n        }\n    }\n\n    fn mount(\n        &mut self,\n        parent: &crate::renderer::types::Element,\n        marker: Option<&crate::renderer::types::Node>,\n    ) {\n        if self.showing_b {\n            self.b\n                .as_mut()\n                .expect(\"B was not present\")\n                .mount(parent, marker);\n        } else {\n            self.a\n                .as_mut()\n                .expect(\"A was not present\")\n                .mount(parent, marker);","sourceCodeStart":702,"sourceCodeEnd":738,"githubUrl":"https://github.com/leptos-rs/leptos/blob/32d20f6c9d517451d77beb68d88c7716823dac41/tachys/src/view/either.rs#L702-L738","documentation":"An Either view was expected to contain variant A (e.g. via into_inner_a or A-extraction logic) but variant B was present. This indicates the Either's inner branch was not the one assumed — a logic mismatch between how the Either was constructed and how it is consumed.","triggerScenarios":"Calling unmount on an EitherKeepAliveState with showing_b == false and a == None — state never had the A view filled, or a was cleared by a switch to B while the flag was later reset.","commonSituations":"Double unmount of a conditional view; manual state construction missing the A view; switching branches then unmounting without letting the update path refill the new active side.","solutions":["Ensure the active side is always Some via the standard update/mount flow before unmounting.","Make unmount idempotent by tracking whether the view is still mounted.","In debug builds, assert (!showing_b implies a.is_some()) before unmount."],"exampleFix":"// before\nstate.showing_b = true;\nstate.a = None;\nstate.showing_b = false;\nstate.unmount(); // panics: a is None\n// after\nstate.a = Some(new_view_a);\nstate.showing_b = false;\nstate.unmount();","handlingStrategy":"validation","validationCode":"if !state.showing_b && state.a.is_some() {\n    state.unmount();\n}","typeGuard":"fn a_unmountable<A, B>(state: &EitherKeepAliveState<A, B>) -> bool {\n    state.showing_b || true /* a.is_some() */\n}","tryCatchPattern":"std::panic::catch_unwind(|| state.unmount())\n    .inspect_err(|_| eprintln!(\"unmount called while A branch slot was empty\"));","preventionTips":["Make unmount idempotent in wrappers around the state.","After switching branches, confirm the new active side is filled before teardown.","Use debug_assert!(state.a.is_some()) when !showing_b.","Construct state only via the library's API."],"tags":["client-side","unmount","either-view","panic","lifecycle"],"backgroundTag":"unfilled-either-branch","analyzedSha":"32d20f6c9d517451d77beb68d88c7716823dac41","analyzedAt":"2026-09-01T18:55:42.580Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T01:17:15.007Z"}