{"record":{"id":"82f30a9226a773ea","repo":"AprilNEA/OpenLogi","slug":"no-online-device-matches-device-q-online-devices-list","errorCode":null,"errorMessage":"no online device matches `--device {q}`.\n  online devices:\n{list}","messagePattern":"no online device matches `--device (.+?)`\\.\n  online devices:\n(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/openlogi-cli/src/cmd/diag.rs","lineNumber":93,"sourceCode":"                .unwrap_or_else(|| format!(\"Slot {}\", paired.slot));\n            out.push(Candidate { route, name });\n        }\n    }\n    Ok(out)\n}\n\n/// Build a helpful \"couldn't pick a device\" error that lists what *is* online.\nfn no_match_err(devices: &[Candidate], query: Option<&str>) -> anyhow::Error {\n    if devices.is_empty() {\n        return anyhow!(\"no online HID++ device found — is a Logi device paired and awake?\");\n    }\n    let list = devices\n        .iter()\n        .map(|c| format!(\"    - {} ({})\", c.name, c.route))\n        .collect::<Vec<_>>()\n        .join(\"\\n\");\n    match query {\n        Some(q) => anyhow!(\"no online device matches `--device {q}`.\\n  online devices:\\n{list}\"),\n        None => anyhow!(\n            \"could not pick a device automatically.\\n  online devices:\\n{list}\\n  \\\n             pass --device <name> to choose one.\"\n        ),\n    }\n}\n\n/// Pick the device a diag should run against.\n///\n/// Selection order:\n/// 1. If `query` is set, the first online device whose name contains it\n///    (case-insensitive) — lets the user disambiguate explicitly.\n/// 2. Else, if `required_features` is non-empty, the first online device whose\n///    HID++ feature table exposes *any* of them. This is what stops a\n///    mouse-only diag (DPI, SmartShift) from picking a paired keyboard when\n///    several devices are online — a real hazard on Bluetooth-direct setups\n///    where each device enumerates as its own inventory.\n/// 3. Else, the first online device (the original behaviour).","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/AprilNEA/OpenLogi/blob/e846e6f4b4405e33bd6a9aaf949a482ce34cb6d8/crates/openlogi-cli/src/cmd/diag.rs#L75-L111","documentation":"Thrown by `no_match_err` when at least one HID++ device is online but none matches the user's `--device <q>` query. The error lists every online device as `name (route)` lines so the user can correct the query. Unlike the empty-list case, this proves enumeration works and the failure is purely name matching.","triggerScenarios":"Running a diagnostic subcommand with `--device <q>` where `<q>` does not case-insensitively match any online candidate's name — misspelled device name, querying a device that is offline while others are online, or using a partial name shorter/longer than the matcher accepts.","commonSituations":"Scripting with a hardcoded device name after the device was renamed or replaced; two similar Logitech devices where the wrong one's name was recorded; device asleep so only its siblings enumerate.","solutions":["Copy the exact name from the error's `online devices:` list and re-run with that value.","If the intended device is absent from the list, wake or reconnect it, then retry.","Drop `--device` to let automatic selection pick the single online device (works when exactly one matches).","Update the hardcoded name in your script/alias to the current device name."],"exampleFix":"// before\n$ openlogi diag dpi --device \"MX Master 3\"\n// error: ... matches `--device MX Master 3`\n// after: use the exact listed name\n$ openlogi diag dpi --device \"MX Master 3S\"","handlingStrategy":"validation","validationCode":"// verify the query matches an online device before invoking the command\nlet devices = enumerate_candidates()?;\nlet q = std::env::var(\"DEV\").unwrap_or_default();\nif !devices.iter().any(|d| d.name.eq_ignore_ascii_case(&q)) {\n    eprintln!(\"{q} not online; online: {}\", devices.iter().map(|d| d.name.as_str()).collect::<Vec<_>>().join(\", \"));\n}","typeGuard":null,"tryCatchPattern":"// on mismatch, fall back to printing the online list and exiting non-fatally\nmatch run_with_query(query) {\n    Err(e) if msg_contains(&e, \"no online device matches\") => {\n        print_online_devices()?; // mirror the error's list for the user\n    }\n    other => other?,\n}","preventionTips":["Copy `--device` values verbatim from the `online devices:` list the error prints.","Don't hardcode device names in scripts; resolve them from `openlogi list` at runtime.","Update names after device swaps/renames — Logitech names include model suffixes (e.g. 3S).","Wake the target device; a sleeping device drops out of the online list."],"tags":["cli","hidpp","device-selection"],"backgroundTag":"resource-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"}