denisidoro/navi · error
Unable to get query
Error message
Unable to get query
What it means
Same stdin protocol as [22]: the `var_stdin` preview reads `<selection><EOF><query><EOF><variable>` from stdin. The second `parts.next()` is the query; if the payload lacks a second field the `expect` panics with "Unable to get query".
Source
Thrown at src/commands/preview/var_stdin.rs:18
use clap::Args;
use super::var;
use crate::common::shell::{self, ShellSpawnError, EOF};
use crate::prelude::*;
use std::io::{self, Read};
#[derive(Debug, Clone, Args)]
pub struct Input {}
impl Runnable for Input {
fn run(&self) -> Result<()> {
let mut text = String::new();
io::stdin().read_to_string(&mut text)?;
let mut parts = text.split(EOF);
let selection = parts.next().expect("Unable to get selection").to_owned();
let query = parts.next().expect("Unable to get query").to_owned();
let variable = parts.next().expect("Unable to get variable").trim().to_owned();
let input = var::Input {
selection,
query,
variable,
};
input.run()?;
if let Some(extra) = parts.next() {
if !extra.is_empty() {
print!("");
let mut cmd = shell::out();
cmd.arg(extra);
debug!(?cmd);
cmd.spawn().map_err(|e| ShellSpawnError::new(extra, e))?.wait()?;View on GitHub (pinned to f7330b9ad5)
Solutions
- Confirm the finder preview command passes the QUERY placeholder in the correct position (second field, before the EOF delimiter)
- Update the finder config template to match this CLI's expected `<selection><EOF><query><EOF><variable>` format
- Test by piping a full three-field payload into the preview command manually
- Replace the `expect` with `ok_or_else` + `?` for a graceful error
Example fix
// before
let query = parts.next().expect("Unable to get query").to_owned();
// after
let query = parts.next().ok_or_else(|| anyhow!("Unable to get query from stdin payload"))?.to_owned(); Defensive patterns
Strategy: validation
Validate before calling
let fields: Vec<&str> = text.split(EOF).collect();
if fields.len() < 2 || fields[1].is_empty() {
eprintln!("stdin payload missing query field");
} Type guard
fn has_query(text: &str) -> bool {
text.split(EOF).nth(1).map_or(false, |q| !q.is_empty())
} Try / catch
let query = text.split(EOF).nth(1)
.ok_or_else(|| anyhow!("no query in stdin payload"))?;
// validate payload shape before parsing rather than catching panics Prevention
- Ensure the finder preview template includes the QUERY placeholder as the second field
- Version-lock finder config with the CLI version
- Smoke-test preview invocations with a scripted payload
- Log raw stdin when debugging preview panics
When it happens
Trigger: The stdin payload contained a selection but no query segment — i.e. only one field before EOF, or the stream ended after the first field.
Common situations: Finder preview template not updated to pass the QUERY placeholder; older/newer finder emitting a different number of fields; hand-crafted preview invocation missing the query.
Related errors
- Unable to get selection
- Unable to get variable
- Unable to process value
- No variables received from finder
- Unable to parse {path}
AI-assisted analysis of denisidoro/navi@f7330b9ad5 (2026-09-03).
Data as JSON: /api/errors/3689632106720fbe.
Report an issue: GitHub.