{"record":{"id":"5ffd8f9373bde456","repo":"nushell/nushell","slug":"output-type-flag","errorCode":null,"errorMessage":"output-type flag","messagePattern":"output-type flag","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/nu_plugin_query/src/query_xml.rs","lineNumber":265,"sourceCode":"        Ok(xpath) => xpath.ok_or_else(|| {\n            LabeledError::new(\"invalid xpath query\").with_label(\"the query must not be empty\", span)\n        }),\n        Err(err) => Err(LabeledError::new(\"invalid xpath query\").with_label(err.to_string(), span)),\n    }\n}\n\nstruct NodeOutputOptions {\n    string_value: bool,\n    type_: bool,\n    names: bool,\n}\n\nimpl NodeOutputOptions {\n    fn from_call(call: &EvaluatedCall) -> Self {\n        match (\n            call.has_flag(\"output-string-value\")\n                .expect(\"output-string-value flag\"),\n            call.has_flag(\"output-type\").expect(\"output-type flag\"),\n            call.has_flag(\"output-names\").expect(\"output-names flag\"),\n        ) {\n            // no flags - old behavior - single column\n            (false, false, false) => NodeOutputOptions {\n                string_value: true,\n                type_: false,\n                names: false,\n            },\n            (string_value, type_, names) => NodeOutputOptions {\n                string_value,\n                type_,\n                names,\n            },\n        }\n    }\n}\n\n#[cfg(test)]","sourceCodeStart":247,"sourceCodeEnd":283,"githubUrl":"https://github.com/nushell/nushell/blob/8e03210652f3c48c4521cec982d96e4cb6c67181/crates/nu_plugin_query/src/query_xml.rs#L247-L283","documentation":"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.","triggerScenarios":"`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.","commonSituations":"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.","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"],"exampleFix":"// before\ncall.has_flag(\"output-type\").expect(\"output-type flag\"),\n\n// after\ncall.has_flag(\"output-type\")\n    .map_err(|err| LabeledError::new(\"could not read --output-type\").with_inner(err))?,","handlingStrategy":"validation","validationCode":"# verify the running query plugin was built for this shell\nplugin list | where name == query | get 0.version\nversion | get version   # the two should correspond to the same release","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["nushell","plugin","query-xml","panic","signature-mismatch","invariant"],"backgroundTag":"plugin-registration-mismatch","analyzedSha":"8e03210652f3c48c4521cec982d96e4cb6c67181","analyzedAt":"2026-08-17T16:24:07.527Z","contentChangedAt":"2026-08-17T16:24:07.527Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}