{"record":{"id":"75f2d376d5a24933","repo":"pbakaus/impeccable","slug":"usage-latest-slug-or-target-json","errorCode":null,"errorMessage":"usage: latest <slug-or-target> [--json]\n","messagePattern":"usage: latest <slug-or-target> \\[--json\\]\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/context/src/critique_storage.rs","lineNumber":545,"sourceCode":"            match written {\n                Some(fp) => {\n                    io.out(&format!(\"{}\\n\", fp));\n                    0\n                }\n                None => {\n                    io.err(&format!(\"{}\\n\", uncaught(&format!(\"Too many critique snapshots for {} at {}\", slug, timestamp))));\n                    1\n                }\n            }\n        }\n        \"latest\" => {\n            let target = rest.first().map(String::as_str).unwrap_or(\"\");\n            let format = rest.get(1).map(String::as_str);\n            let slugs = slug_candidates(rest.first().map(String::as_str), &cwd);\n            // JS: format && format !== '--json'  (format truthy = non-empty)\n            let bad_format = format.map(|f| !f.is_empty() && f != \"--json\").unwrap_or(false);\n            if slugs.is_empty() || bad_format {\n                io.err(\"usage: latest <slug-or-target> [--json]\\n\");\n                return 1;\n            }\n            let format_is_json = format == Some(\"--json\");\n            let target_fingerprint = fingerprint_target(target, &cwd);\n            let target_path = resolve_local_target_path(target, &cwd);\n            let target_identity = resolve_target_identity(target, &cwd);\n            let ready_slug = is_ready_slug(target);\n            let Some(newest_for_slug) =\n                read_newest_safe_snapshot_for_slugs(&slugs, target_identity.as_deref(), &cwd, &env)\n            else {\n                return 2;\n            };\n            let mut latest =\n                read_newest_snapshot_for_identity_slugs(&slugs, target_identity.as_deref(), &cwd, &env);\n            if latest.is_none() && !ready_slug {\n                // Identity-less snapshots are safe only under the new/current\n                // collision-resistant slug. A pre-hash slug suffix alone cannot\n                // prove which long target owned the historical snapshot.","sourceCodeStart":527,"sourceCodeEnd":563,"githubUrl":"https://github.com/pbakaus/impeccable/blob/2bc2879276c1f321a53c4ca99d3371e411329b52/crates/context/src/critique_storage.rs#L527-L563","documentation":"The `latest` subcommand validates its arguments before doing work: it requires a resolvable slug-or-target and, if a second argument is given, it must be exactly `--json`. Anything else prints this usage line to stderr and exits 1.","triggerScenarios":"Running `critique-storage latest` with no argument; with a first argument that yields no slug candidates (empty or unresolvable target); or with a second argument that is not `--json` (e.g. `--JSON`, `-json`, `json`, or an extra stray flag).","commonSituations":"Typos like `--json=v1` or `latest mytarget --json extra`; running from a directory where the target slug cannot be resolved; scripting the command with a variable that expands to an empty string.","solutions":["Pass exactly one argument: the slug or a resolvable target path (use an explicit `./path` for local targets).","If you want JSON, pass the literal flag `--json` as the second argument with nothing after it.","Verify the slug resolves: `impeccable critique-storage slug <target>` should print a non-empty slug.","Quote shell variables so an empty arg is not silently dropped or split."],"exampleFix":"// before\nlatest mytarget --JSON\n// after\nlatest mytarget --json","handlingStrategy":"validation","validationCode":"const args = ['latest', target];\nif (wantJson) args.push('--json');\nconst slug = runCapture('impeccable', ['critique-storage', 'slug', target]).stdout.trim();\nif (!slug) throw new Error('target does not resolve to a slug');","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass the slug/target as the first and only positional argument.","Use the exact literal `--json` flag when JSON output is needed.","Resolve the target with the `slug` subcommand before calling latest.","Quote shell variables to avoid empty or split arguments."],"tags":["cli","usage","invalid-argument","argument-parsing"],"backgroundTag":"invalid-cli-argument","analyzedSha":"2bc2879276c1f321a53c4ca99d3371e411329b52","analyzedAt":"2026-09-08T04:51:14.109Z","contentChangedAt":"2026-09-08T04:51:14.109Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}