sxyazi/yazi · warning

Invalid value for the name property

Error message

Invalid value for the name property

What it means

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.

Source

Thrown at yazi-fs/src/mounts/macos.rs:171

		}

		names.sort_unstable_by(|a, b| natsort(a.as_bytes(), b.as_bytes(), false));
		Ok(names)
	}

	fn bsd_name(service: mach_port_t) -> Result<CString> {
		let key = CFString::new("BSD Name")?;
		let property =
			unsafe { IORegistryEntryCreateCFProperty(service, *key, kCFAllocatorDefault, 1) };
		if property.is_null() {
			bail!("Cannot get the name property");
		}
		defer! { unsafe { CFRelease(property) } };

		#[allow(unexpected_cfgs)]
		let cstr: *const c_char = unsafe { msg_send![property as *const AnyObject, UTF8String] };
		Ok(if cstr.is_null() {
			bail!("Invalid value for the name property");
		} else {
			CString::from(unsafe { CStr::from_ptr(cstr) })
		})
	}
}

View on GitHub (pinned to 5f901b886b)

Solutions

  1. Verify the property type with `CFGetTypeID`/`NSStringFromClass` before messaging `UTF8String`, and use `CFStringGetCStringPtr`/`CFStringGetCString` for CFString-safe conversion.
  2. Skip services whose BSD Name value is not a string.
  3. Update macOS / check for third-party kexts publishing malformed registry entries.

Example fix

// before
let cstr: *const c_char = unsafe { msg_send![property as *const AnyObject, UTF8String] };
if cstr.is_null() { bail!("Invalid value for the name property"); }
// after: check type first
let prop = property as *const AnyObject;
let cls: *const AnyObject = unsafe { msg_send![prop, class] };
let nsstring: *const AnyObject = unsafe { msg_send![class!(NSString), class] };
if cls != nsstring { return Ok(None); }
Defensive patterns

Strategy: type-guard

Type guard

fn is_cf_string(prop: *const AnyObject) -> bool {
    let typeid = unsafe { CFGetTypeID(prop as *const _) };
    typeid == unsafe { CFStringGetTypeID() }
}

Try / catch

match bsd_name(service) {
    Ok(name) => Some(name),
    Err(_) if !is_cf_string(property) => None, // skip non-string value
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: 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`.

Common situations: 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.

Related errors


AI-assisted analysis of sxyazi/yazi@5f901b886b (2026-09-02). Data as JSON: /api/errors/979962c9102fa57c. Report an issue: GitHub.