AprilNEA/OpenLogi · error

the selected direct device is absent from the Agent snapshot

Error message

the selected direct device is absent from the Agent snapshot

What it means

Raised in `capture_inventory` when the receiver has no unique_id (a direct/bluetooth connection) and `source.paired.get(selected_device)` is `None`. For direct devices the code retains only the selected paired device, so if the selected index is absent from the inventory's `paired` vec the capture cannot proceed. It means the CLI's device selection pointed at a device the snapshot does not actually contain.

Solutions

  1. Re-run `openlogi list` and select the device from the current output; the snapshot was likely stale.
  2. Reconnect the device and confirm it appears in a fresh snapshot before recording.
  3. If persistent, verify the device connects directly (no receiver) and is enumerated by the agent; restart the agent.

Example fix

// stale selection
openlogi fixture record profile --device "Old Route" ...
// after: refresh inventory first
openlogi list
openlogi fixture record profile --device "Current Route" ...
Defensive patterns

Strategy: validation

Validate before calling

let ok = inventory.receiver.unique_id.is_none() && selected_device < inventory.paired.len();
if !ok { eprintln!("selected device not in current snapshot; re-run openlogi list"); }

Try / catch

// treat the anyhow error as stale-selection and retry once with a fresh snapshot
match capture_inventory(client, source, idx).await {
    Err(e) if e.to_string().contains("absent from the Agent snapshot") => retry_with_fresh_snapshot().await,
    other => other,
}

Prevention

When it happens

Trigger: Running `openlogi fixture record profile --device <selector>` where the selector resolves to a device index that is out of bounds of `DeviceInventory.paired` for a direct (receiver-less) connection.

Common situations: Device disconnected and the snapshot shrank between listing and selection; the user passed a rendered route from an older `openlogi list` output; a Bolt/BT device dropped and rejoined changing slot ordering.

Understand the failure class

Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.

Related errors


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

Appendix: source

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

            id,
            name,
            inventories,
            standalone,
            settings,
        },
        selected_route,
    })
}

async fn capture_inventory(
    client: &AgentClient,
    source: &DeviceInventory,
    selected_device: usize,
) -> Result<ProfileCaptureParts> {
    let mut retained = source.clone();
    if retained.receiver.unique_id.is_none() {
        retained.paired = vec![source.paired.get(selected_device).cloned().ok_or_else(|| {
            anyhow!("the selected direct device is absent from the Agent snapshot")
        })?];
    }

    let source_routes = retained
        .paired
        .iter()
        .map(|device| {
            DeviceRoute::device_route_for(&retained, device.slot).ok_or_else(|| {
                anyhow!("a retained Agent inventory route is not safely addressable")
            })
        })
        .collect::<Result<Vec<_>>>()?;
    let retained_selected = if retained.receiver.unique_id.is_none() {
        0
    } else {
        selected_device
    };
    sanitize::inventory(&mut retained)?;

View on GitHub (pinned to e846e6f4b4)