{"record":{"id":"2773313f797ceee9","repo":"AprilNEA/OpenLogi","slug":"the-selected-direct-device-is-absent-from-the-agent-snapshot","errorCode":null,"errorMessage":"the selected direct device is absent from the Agent snapshot","messagePattern":"the selected direct device is absent from the Agent snapshot","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/openlogi-cli/src/cmd/fixture/record_profile.rs","lineNumber":227,"sourceCode":"            id,\n            name,\n            inventories,\n            standalone,\n            settings,\n        },\n        selected_route,\n    })\n}\n\nasync fn capture_inventory(\n    client: &AgentClient,\n    source: &DeviceInventory,\n    selected_device: usize,\n) -> Result<ProfileCaptureParts> {\n    let mut retained = source.clone();\n    if retained.receiver.unique_id.is_none() {\n        retained.paired = vec![source.paired.get(selected_device).cloned().ok_or_else(|| {\n            anyhow!(\"the selected direct device is absent from the Agent snapshot\")\n        })?];\n    }\n\n    let source_routes = retained\n        .paired\n        .iter()\n        .map(|device| {\n            DeviceRoute::device_route_for(&retained, device.slot).ok_or_else(|| {\n                anyhow!(\"a retained Agent inventory route is not safely addressable\")\n            })\n        })\n        .collect::<Result<Vec<_>>>()?;\n    let retained_selected = if retained.receiver.unique_id.is_none() {\n        0\n    } else {\n        selected_device\n    };\n    sanitize::inventory(&mut retained)?;","sourceCodeStart":209,"sourceCodeEnd":245,"githubUrl":"https://github.com/AprilNEA/OpenLogi/blob/e846e6f4b4405e33bd6a9aaf949a482ce34cb6d8/crates/openlogi-cli/src/cmd/fixture/record_profile.rs#L209-L245","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Re-run `openlogi list` and select the device from the current output; the snapshot was likely stale.","Reconnect the device and confirm it appears in a fresh snapshot before recording.","If persistent, verify the device connects directly (no receiver) and is enumerated by the agent; restart the agent."],"exampleFix":"// stale selection\nopenlogi fixture record profile --device \"Old Route\" ...\n// after: refresh inventory first\nopenlogi list\nopenlogi fixture record profile --device \"Current Route\" ...","handlingStrategy":"validation","validationCode":"let ok = inventory.receiver.unique_id.is_none() && selected_device < inventory.paired.len();\nif !ok { eprintln!(\"selected device not in current snapshot; re-run openlogi list\"); }","typeGuard":null,"tryCatchPattern":"// treat the anyhow error as stale-selection and retry once with a fresh snapshot\nmatch capture_inventory(client, source, idx).await {\n    Err(e) if e.to_string().contains(\"absent from the Agent snapshot\") => retry_with_fresh_snapshot().await,\n    other => other,\n}","preventionTips":["Always select the device from a just-fetched snapshot, not cached `openlogi list` output.","Re-run `openlogi list` immediately before `fixture record profile` when devices change.","Verify the device is connected and online before recording."],"tags":["rust","cli","device-selection","stale-snapshot"],"backgroundTag":"record-not-found","analyzedSha":"e846e6f4b4405e33bd6a9aaf949a482ce34cb6d8","analyzedAt":"2026-09-13T03:07:16.451Z","contentChangedAt":"2026-09-13T03:07:16.451Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}