{"record":{"id":"31731f96dc15c0d1","repo":"slint-ui/slint","slug":"cannot-get-property-name-e","errorCode":null,"errorMessage":"Cannot get property {name}: {e}","messagePattern":"Cannot get property (.+?): (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/live-preview/live_component.rs","lineNumber":194,"sourceCode":"\n    /// Return the instance\n    pub fn instance(&self) -> &ComponentInstance {\n        self.instance.as_ref().expect(\"always set after Self is created from Rc::new_cyclic\")\n    }\n\n    /// Set a property and remember its value for when the component is reloaded\n    pub fn set_property(&self, name: &str, value: Value) {\n        self.properties.borrow_mut().insert(name.into(), value.clone());\n        self.instance()\n            .set_property(name, value)\n            .unwrap_or_else(|e| panic!(\"Cannot set property {name}: {e}\"))\n    }\n\n    /// Forward to get_property\n    pub fn get_property(&self, name: &str) -> Value {\n        self.instance()\n            .get_property(name)\n            .unwrap_or_else(|e| panic!(\"Cannot get property {name}: {e}\"))\n    }\n\n    /// Forward to invoke\n    pub fn invoke(&self, name: &str, args: &[Value]) -> Value {\n        self.instance()\n            .invoke(name, args)\n            .unwrap_or_else(|e| panic!(\"Cannot invoke callback {name}: {e}\"))\n    }\n\n    /// Forward to set_callback\n    pub fn set_callback(&self, name: &str, callback: Rc<dyn Fn(&[Value]) -> Value + 'static>) {\n        self.callbacks.borrow_mut().insert(name.into(), callback.clone());\n        self.instance()\n            .set_callback(name, move |args| callback(args))\n            .unwrap_or_else(|e| panic!(\"Cannot set callback {name}: {e}\"));\n    }\n\n    /// forward to set_global_property","sourceCodeStart":176,"sourceCodeEnd":212,"githubUrl":"https://github.com/slint-ui/slint/blob/3a7e700487dc74d404cad0726378053ab763d4e0/internal/live-preview/live_component.rs#L176-L212","documentation":"Panic in live-preview's get_property when the interpreter instance cannot return the requested property value — typically the property does not exist or the caller supplied a value of the wrong type to deserialize into.","triggerScenarios":"Calling LiveComponent::get_property with a name not present on the component, or a template/type mismatch between the requested Rust type and the property's declared type.","commonSituations":"Reading a property after a .slint edit renamed or removed it; querying a property that lives on a sub-element or global without the right name; asking for i32 when the property is a length (f32-like) or string.","solutions":["Verify the property name and its declared type; request the matching Rust type.","Use the interpreter instance API (get_property returning Result) to handle the error gracefully instead of panicking.","Re-load the component after .slint edits before reading properties.","For globals, use get_global_property with the correct global and property names."],"exampleFix":"// before\nlet n: i32 = live.get_property(\"items_count\"); // property doesn't exist\n// after\nlet n: i32 = live.get_property(\"item-count\"); // match the declared property<int> item-count","handlingStrategy":"try-catch","validationCode":"// Check the property is declared before reading\n// if instance.definition().properties(name).iter().any(|p| p.name == prop) { ... }","typeGuard":"fn get_typed<T: TryFrom<Value>>(live: &LiveComponent, name: &str) -> Option<T> {\n    std::panic::catch_unwind(|| live.get_property(name)).ok().and_then(T::try_from).ok()\n}","tryCatchPattern":"match instance.get_property(name) {\n    Ok(v) => v,\n    Err(e) => { eprintln!(\"get_property {name} failed: {e}\"); Value::default() }\n}","preventionTips":["Use exact property names from the .slint source (kebab-case).","Request the Rust type matching the declared property type.","Re-load the component after edits before reading properties."],"tags":["live-preview","property","lookup-failure","panic"],"backgroundTag":"record-not-found","analyzedSha":"3a7e700487dc74d404cad0726378053ab763d4e0","analyzedAt":"2026-09-16T01:37:20.251Z","contentChangedAt":"2026-09-16T01:37:20.251Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}