nushell/nushell · error
output-type flag
Error message
output-type flag
What it means
Same internal-invariant guard as its siblings, but for the --output-type switch: NodeOutputOptions::from_call expects has_flag("output-type") to always succeed because `query xml`'s signature() declares that switch (query_xml.rs:47-51). has_flag fails only if the engine delivers the flag with a non-boolean value over the plugin protocol. A panic here indicates the plugin binary and the engine's view of the command signature are out of sync, not a bad XPath query or bad input.
Source
Thrown at crates/nu_plugin_query/src/query_xml.rs:265
Ok(xpath) => xpath.ok_or_else(|| {
LabeledError::new("invalid xpath query").with_label("the query must not be empty", span)
}),
Err(err) => Err(LabeledError::new("invalid xpath query").with_label(err.to_string(), span)),
}
}
struct NodeOutputOptions {
string_value: bool,
type_: bool,
names: bool,
}
impl NodeOutputOptions {
fn from_call(call: &EvaluatedCall) -> Self {
match (
call.has_flag("output-string-value")
.expect("output-string-value flag"),
call.has_flag("output-type").expect("output-type flag"),
call.has_flag("output-names").expect("output-names flag"),
) {
// no flags - old behavior - single column
(false, false, false) => NodeOutputOptions {
string_value: true,
type_: false,
names: false,
},
(string_value, type_, names) => NodeOutputOptions {
string_value,
type_,
names,
},
}
}
}
#[cfg(test)]View on GitHub (pinned to 8e03210652)
Solutions
- Re-register the plugin: `plugin rm query` then `plugin add /path/to/nu_plugin_query` so the engine re-reads the current signature
- Reinstall the plugin built against the running shell: `cargo install nu_plugin_query --locked` with nushell and plugin from the same release
- Check that flag name strings in from_call ('output-type') match the switches in signature() character-for-character
- Propagate the error instead of expecting: map the has_flag Result into LabeledError so callers see a readable error rather than a crashed plugin
Example fix
// before
call.has_flag("output-type").expect("output-type flag"),
// after
call.has_flag("output-type")
.map_err(|err| LabeledError::new("could not read --output-type").with_inner(err))?, Defensive patterns
Strategy: validation
Validate before calling
# verify the running query plugin was built for this shell plugin list | where name == query | get 0.version version | get version # the two should correspond to the same release
Prevention
- Keep plugin and host nushell versions in lockstep; reinstall plugins whenever the shell is upgraded
- Clear plugin registration caches when switching between distro and self-compiled nushell
- In forked plugin code, keep signature() switches and from_call flag lookups in the same commit
- Replace .expect() in from_call with map_err into LabeledError so mismatches produce readable errors
When it happens
Trigger: `query xml '...' --output-type` executed with a stale cached plugin registration after a nushell upgrade; nu_plugin_query binary compiled against a different nu-plugin-protocol than the running shell; a fork that renamed/removed the 'output-type' switch in signature() without updating from_call.
Common situations: Mixed-version installs (system nushell + locally built plugins); plugin cache files carried over between nushell versions via a shared config dir; CI images where plugins are cached but nushell is bumped.
Related errors
- output-string-value flag
- output-names flag
- we guarantee that 1 entry is always in a list
- always ok
- we know that we have a table cause of a flag
AI-assisted analysis of nushell/nushell@8e03210652 (2026-08-17).
Data as JSON: /api/errors/5ffd8f9373bde456.
Report an issue: GitHub.