AprilNEA/OpenLogi · error

the sanitized selected profile route is absent

Error message

the sanitized selected profile route is absent

What it means

Raised in `capture_inventory` when `profile_routes.get(retained_selected)` is `None` — the index of the selected device does not resolve into the sanitized route list. Since `retained_selected` is derived from `selected_device` (or forced to 0 for direct devices) and `profile_routes` mirrors `retained.paired`, this means sanitization changed the paired list length/order relative to the selection index.

Solutions

  1. Fix `sanitize::inventory` to keep the selected device or to remap the selected index rather than leaving it stale.
  2. Ensure the selected index is only computed after sanitization, or adjusted when sanitizer removes devices.
  3. As a user, retry with an explicit `--device` selector on a fresh snapshot; if it persists, it is a CLI sanitizer bug.

Example fix

// before: index computed before sanitize, used after
let retained_selected = selected_device;
sanitize::inventory(&mut retained)?;
// after: remap selection through sanitize, or sanitize first then reselect
sanitize::inventory(&mut retained)?;
let retained_selected = retained.paired.iter().position(|d| d.slot == original_slot).ok_or_else(|| anyhow!("selected device was pruned during sanitization"))?;
Defensive patterns

Strategy: validation

Validate before calling

let retained_selected = retained.paired.iter().position(|d| d.slot == original_slot)
    .ok_or_else(|| anyhow!("selected device pruned during sanitization"))?;

Prevention

When it happens

Trigger: `capture_inventory` computes `retained_selected = selected_device` for receiver-backed inventories, then `sanitize::inventory` prunes or reorders `retained.paired` so the selected index no longer exists in the sanitized list.

Common situations: Sanitizer pruning drops devices before the selected one (shifting indices) or drops the selected device itself; selecting a device index from pre-sanitize data and applying it post-sanitize.

Related errors


AI-assisted analysis of AprilNEA/OpenLogi@e846e6f4b4 (2026-09-13). Data as JSON: /api/errors/d600f3f7212f40c8. Report an issue: GitHub.

Appendix: source

Thrown at crates/openlogi-cli/src/cmd/fixture/record_profile.rs:257

        .collect::<Result<Vec<_>>>()?;
    let retained_selected = if retained.receiver.unique_id.is_none() {
        0
    } else {
        selected_device
    };
    sanitize::inventory(&mut retained)?;
    let profile_routes = retained
        .paired
        .iter()
        .map(|device| {
            DeviceRoute::device_route_for(&retained, device.slot)
                .ok_or_else(|| anyhow!("a sanitized profile route is not addressable"))
        })
        .collect::<Result<Vec<_>>>()?;
    let selected_route = profile_routes
        .get(retained_selected)
        .cloned()
        .ok_or_else(|| anyhow!("the sanitized selected profile route is absent"))?;

    let mut settings = Vec::with_capacity(retained.paired.len());
    for ((source_route, profile_route), device) in source_routes
        .iter()
        .zip(profile_routes)
        .zip(&retained.paired)
    {
        settings.push(capture_hidpp_settings(client, source_route, profile_route, device).await?);
    }
    Ok((vec![retained], Vec::new(), settings, selected_route))
}

async fn capture_hidpp_settings(
    client: &AgentClient,
    source_route: &DeviceRoute,
    profile_route: DeviceRoute,
    device: &PairedDevice,
) -> Result<ProfileDeviceSettings> {

View on GitHub (pinned to e846e6f4b4)