{"record":{"id":"02b5e63c9eee4e1e","repo":"neondatabase/neon","slug":"need-1-n-positional-arguments-describing-the-key","errorCode":null,"errorMessage":"need 1..N positional arguments describing the key, try hex or a log line","messagePattern":"need 1\\.\\.N positional arguments describing the key, try hex or a log line","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pageserver/ctl/src/key.rs","lineNumber":183,"sourceCode":"\nimpl From<KeyMaterial> for Key {\n    fn from(value: KeyMaterial) -> Self {\n        match value {\n            KeyMaterial::Hex(key) => key,\n            KeyMaterial::String(SpanAttributesFromLogs(rt, blocknum))\n            | KeyMaterial::Split(rt, blocknum) => {\n                pageserver_api::key::rel_block_to_key(rt, blocknum)\n            }\n        }\n    }\n}\n\nimpl<S: AsRef<str>> TryFrom<&[S]> for KeyMaterial {\n    type Error = anyhow::Error;\n\n    fn try_from(value: &[S]) -> Result<Self, Self::Error> {\n        match value {\n            [] => anyhow::bail!(\n                \"need 1..N positional arguments describing the key, try hex or a log line\"\n            ),\n            [one] => {\n                let one = one.as_ref();\n\n                let key = Key::from_hex(one).map(KeyMaterial::Hex);\n\n                let attrs = SpanAttributesFromLogs::from_str(one).map(KeyMaterial::String);\n\n                match (key, attrs) {\n                    (Ok(key), _) => Ok(key),\n                    (_, Ok(s)) => Ok(s),\n                    (Err(e1), Err(e2)) => anyhow::bail!(\n                        \"failed to parse {one:?} as hex or span attributes:\\n- {e1:#}\\n- {e2:#}\"\n                    ),\n                }\n            }\n            more => {","sourceCodeStart":165,"sourceCodeEnd":201,"githubUrl":"https://github.com/neondatabase/neon/blob/8f60b04da47ffefe0e52bda2440134b42874eb75/pageserver/ctl/src/key.rs#L165-L201","documentation":"The pageserver_ctl key subcommand builds a Key from 1..N positional arguments. An empty argument list cannot describe a key, so it bails immediately with a hint listing the accepted forms: a hex key, or a pasted log line, or a reltag plus block number.","triggerScenarios":"Invoking the key subcommand with zero positional arguments.","commonSituations":"An unset shell variable that expands to nothing ($KEY with KEY empty); scripts that pass an optional argument unconditionally; quoting mistakes that swallow the argument.","solutions":["Supply at least one argument: a hex key (as printed by the pageserver), a log line containing rel= and blkno=, or a reltag followed by a block number.","Guard scripts with [ -n \"$KEY\" ] or a default value before invoking the ctl."],"exampleFix":"# before\npageserver_ctl key \"$MAYBE_EMPTY\"\n\n# after\npageserver_ctl key \"000000067F000100010000AC0000000006\"","handlingStrategy":"validation","validationCode":"#!/usr/bin/env bash\n# require at least one positional argument\n[ \"$#\" -ge 1 ] || { echo \"usage: pageserver_ctl key <hex-key | log-line | reltag blocknum>\" >&2; exit 1; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check variables with [ -n \"$KEY\" ] before passing them to the ctl.","Print usage from wrapper scripts when no argument is given."],"tags":["rust","neon","ctl","cli","key-parsing"],"backgroundTag":"missing-cli-argument","analyzedSha":"8f60b04da47ffefe0e52bda2440134b42874eb75","analyzedAt":"2026-08-16T23:39:28.135Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}