{"record":{"id":"979962c9102fa57c","repo":"sxyazi/yazi","slug":"invalid-value-for-the-name-property","errorCode":null,"errorMessage":"Invalid value for the name property","messagePattern":"Invalid value for the name property","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"yazi-fs/src/mounts/macos.rs","lineNumber":171,"sourceCode":"\t\t}\n\n\t\tnames.sort_unstable_by(|a, b| natsort(a.as_bytes(), b.as_bytes(), false));\n\t\tOk(names)\n\t}\n\n\tfn bsd_name(service: mach_port_t) -> Result<CString> {\n\t\tlet key = CFString::new(\"BSD Name\")?;\n\t\tlet property =\n\t\t\tunsafe { IORegistryEntryCreateCFProperty(service, *key, kCFAllocatorDefault, 1) };\n\t\tif property.is_null() {\n\t\t\tbail!(\"Cannot get the name property\");\n\t\t}\n\t\tdefer! { unsafe { CFRelease(property) } };\n\n\t\t#[allow(unexpected_cfgs)]\n\t\tlet cstr: *const c_char = unsafe { msg_send![property as *const AnyObject, UTF8String] };\n\t\tOk(if cstr.is_null() {\n\t\t\tbail!(\"Invalid value for the name property\");\n\t\t} else {\n\t\t\tCString::from(unsafe { CStr::from_ptr(cstr) })\n\t\t})\n\t}\n}\n","sourceCodeStart":153,"sourceCodeEnd":177,"githubUrl":"https://github.com/sxyazi/yazi/blob/5f901b886b14de1f17460b6e52e9de5d67f8aba9/yazi-fs/src/mounts/macos.rs#L153-L177","documentation":"After fetching the \"BSD Name\" CFProperty, `bsd_name` calls the ObjC `UTF8String` selector and bails if the resulting C string pointer is NULL. This means the property exists but is not an NSString (or the conversion failed), so it cannot be turned into a `CString`. Essentially a type-safety failure at the ObjC/FFI boundary.","triggerScenarios":"Calling `bsd_name(service)` when the \"BSD Name\" registry property is a non-string CFType (e.g. CFData/CFNumber) so `msg_send![property, UTF8String]` returns NULL, or the property object does not respond to `UTF8String`.","commonSituations":"Exotic kernel extensions or virtualization frameworks publishing \"BSD Name\" as a non-NSString type; memory pressure causing UTF8String to return NULL; future macOS versions changing the property type.","solutions":["Verify the property type with `CFGetTypeID`/`NSStringFromClass` before messaging `UTF8String`, and use `CFStringGetCStringPtr`/`CFStringGetCString` for CFString-safe conversion.","Skip services whose BSD Name value is not a string.","Update macOS / check for third-party kexts publishing malformed registry entries."],"exampleFix":"// before\nlet cstr: *const c_char = unsafe { msg_send![property as *const AnyObject, UTF8String] };\nif cstr.is_null() { bail!(\"Invalid value for the name property\"); }\n// after: check type first\nlet prop = property as *const AnyObject;\nlet cls: *const AnyObject = unsafe { msg_send![prop, class] };\nlet nsstring: *const AnyObject = unsafe { msg_send![class!(NSString), class] };\nif cls != nsstring { return Ok(None); }","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"fn is_cf_string(prop: *const AnyObject) -> bool {\n    let typeid = unsafe { CFGetTypeID(prop as *const _) };\n    typeid == unsafe { CFStringGetTypeID() }\n}","tryCatchPattern":"match bsd_name(service) {\n    Ok(name) => Some(name),\n    Err(_) if !is_cf_string(property) => None, // skip non-string value\n    Err(e) => return Err(e),\n}","preventionTips":["Check CFGetTypeID against CFStringGetTypeID before messaging UTF8String.","Prefer CFStringGetCString over ObjC UTF8String for CFType-safe conversion.","Treat malformed registry values as skip-worthy, not fatal."],"tags":["macos","objc","ffi","type-mismatch"],"backgroundTag":"unexpected-cftype-type","analyzedSha":"5f901b886b14de1f17460b6e52e9de5d67f8aba9","analyzedAt":"2026-09-02T18:38:25.566Z","contentChangedAt":"2026-09-02T18:38:25.566Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}