AprilNEA/OpenLogi · error

. Candidates

Error message

{message}. Candidates:{list}

What it means

Formatted error from `selection_error()` in target_selection.rs, raised when interactive/automatic target selection cannot find or disambiguate a device. The message embeds the caller's reason (`{message}`) plus a bullet list of available candidates with their display names and safe route labels (e.g. 'Bolt receiver slot 2'). It is the CLI's way of telling you exactly which devices were visible when selection failed.

Solutions

  1. Check the Candidates list in the error and use an exact display name or identifier from it
  2. Confirm the device is powered on, awake, and within range of the receiver/dongle
  3. Re-run `openlogi list` to refresh the device inventory, then retry selection
  4. If the device appears under an unexpected route label, re-pair it or move it to another receiver slot

Example fix

null
Defensive patterns

Strategy: validation

Validate before calling

let candidates = standalone_inventory().await?;
let match = candidates.iter().find(|c| c.display_name() == wanted)
    .ok_or_else(|| anyhow!("'{}' not attached; run `openlogi list`", wanted))?;

Type guard

fn known_device(name: &str, candidates: &[Device]) -> Option<&Device> {
    candidates.iter().find(|c| c.display_name() == name)
}

Try / catch

match select_target(&devices, &filter) {
    Ok(device) => apply(device),
    Err(e) if e.to_string().contains("Candidates:") => {
        eprintln!("{}\nRun `openlogi list` and retry with an exact name.", e);
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: `select_target` invoked with a device filter/identifier that matches no enumerated candidate, or with no devices attached, or an ambiguous selection request — from both the inventory and standalone code paths.

Common situations: Typing a partial or misspelled device name in `--device`; the target device is powered off or out of receiver range; device is paired to a different receiver slot than expected; running before the receiver enumerates.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


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

Appendix: source

Thrown at crates/openlogi-cli/src/cmd/fixture/target_selection.rs:64

        return Err(selection_error(
            "the selected route is duplicated and cannot identify one target",
            candidates,
        ));
    }
    Ok(selected)
}

fn selection_error<T: FixtureTarget>(message: &str, candidates: &[T]) -> anyhow::Error {
    let mut list = String::new();
    for candidate in candidates {
        let _ = write!(
            list,
            "\n  - {:?} ({})",
            candidate.display_name(),
            safe_route_label(candidate.route())
        );
    }
    anyhow!("{message}. Candidates:{list}")
}

fn safe_route_label(route: &DeviceRoute) -> String {
    match route {
        DeviceRoute::Bolt { slot, .. } => format!("Bolt receiver slot {slot}"),
        DeviceRoute::Unifying { slot, .. } => format!("Unifying receiver slot {slot}"),
        DeviceRoute::Direct {
            vendor_id,
            product_id,
        } => format!("direct {vendor_id:04x}:{product_id:04x}"),
        DeviceRoute::RawHid {
            vendor_id,
            product_id,
            usage_page,
            usage_id,
            ..
        } => format!(
            "standalone {vendor_id:04x}:{product_id:04x} usage {usage_page:04x}:{usage_id:04x}"

View on GitHub (pinned to e846e6f4b4)