{"record":{"id":"e825a75525913167","repo":"astrid-runtime/astrid","slug":"flag-requires-non-empty-name-path","errorCode":null,"errorMessage":"{flag} requires non-empty NAME=PATH","messagePattern":"(.+?) requires non-empty NAME=PATH","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-storage-chunker-evidence/src/main.rs","lineNumber":228,"sourceCode":"    }\n    Ok((\n        name,\n        PathBuf::from(repository),\n        PathBuf::from(relative_path),\n    ))\n}\n\nfn parse_path_specification(\n    flag: &str,\n    specification: Option<String>,\n) -> Result<(String, PathBuf)> {\n    let specification =\n        specification.ok_or_else(|| anyhow::anyhow!(\"{flag} requires NAME=PATH\"))?;\n    let (name, path) = specification\n        .split_once('=')\n        .ok_or_else(|| anyhow::anyhow!(\"{flag} requires NAME=PATH\"))?;\n    if name.is_empty() || path.is_empty() {\n        bail!(\"{flag} requires non-empty NAME=PATH\");\n    }\n    Ok((name.to_owned(), PathBuf::from(path)))\n}\n\nfn print_help() {\n    println!(\n        \"Usage: astrid-storage-chunker-evidence [OPTIONS]\\n\\\n         \\n\\\n         Options:\\n\\\n         \\x20 --corpus NAME=PATH       Add a directory snapshot; paths stay out of reports\\n\\\n         \\x20 --version-chain NAME=PATH\\n\\\n         \\x20                          Add lexically ordered version files\\n\\\n         \\x20 --git-history NAME=REPO::RELATIVE_PATH\\n\\\n         \\x20                          Add up to 32 real versions without temporary files\\n\\\n         \\x20 --no-synthetic           Exclude deterministic public fixtures\\n\\\n         \\x20 --sketch-only            Skip the CDC comparison and measure sketches only\\n\\\n         \\x20 --target-kib N           Compare profiles around N KiB (repeatable)\\n\\\n         \\x20 --output PATH            Write compact JSON to PATH instead of stdout\\n\\","sourceCodeStart":210,"sourceCodeEnd":246,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-storage-chunker-evidence/src/main.rs#L210-L246","documentation":"The CLI flag (--path-style specification parser) requires a NAME=PATH pair; this fires when the '=' is present but either side is an empty string. parse_path_specification validates that both the logical name and the filesystem path are non-empty before returning them to parse_options or parse_git_specification.","triggerScenarios":"Passing '--flag =/some/path' (empty name), '--flag name=' (empty path), or '--flag =' to any flag handled by parse_path_specification; e.g. a trailing '=' from a shell script variable that came up empty.","commonSituations":"Shell scripts interpolating environment variables like '--flag $NAME=$PATH' where one variable is unset; users typing 'name= ' with trailing whitespace stripped to empty; copy-pasting examples with placeholder names.","solutions":["Supply both a non-empty name and a non-empty path separated by '=', e.g. '--flag evidence=chunks.bin'.","Check the shell variables feeding the flag are set and non-empty (quote them: \"--flag ${NAME}=${PATH}\").","Run the tool with --help (print_help) to see the expected NAME=PATH syntax."],"exampleFix":"// before\nmytool --flag =out.bin\n// after\nmytool --flag evidence=out.bin","handlingStrategy":"validation","validationCode":"fn valid_spec(s: &str) -> bool {\n    match s.split_once('=') {\n        Some((name, path)) => !name.is_empty() && !path.is_empty(),\n        None => false,\n    }\n}","typeGuard":"fn parse_spec(s: &str) -> Option<(String, String)> {\n    s.split_once('=').filter(|(n, p)| !n.is_empty() && !p.is_empty()).map(|(n, p)| (n.to_owned(), p.to_owned()))\n}","tryCatchPattern":"match parse_options(args) {\n    Ok(opts) => run(opts),\n    Err(e) if e.to_string().contains(\"NAME=PATH\") => eprintln!(\"usage: --flag NAME=PATH\\n{e}\"),\n    Err(e) => eprintln!(\"{e:#}\"),\n}","preventionTips":["Quote interpolated shell variables to catch unset values early","Validate NAME=PATH strings in scripts before invoking the CLI","Check --help for exact flag syntax"],"tags":["cli","argument-parsing","validation"],"backgroundTag":"invalid-cli-argument","analyzedSha":"affd8760f44190dbdfbec23403f4c4b642c33112","analyzedAt":"2026-09-09T21:28:12.402Z","contentChangedAt":"2026-09-09T21:28:12.402Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}