{"record":{"id":"0e07fd2e415b8c23","repo":"pbakaus/impeccable","slug":"usage-write-slug-or-target-body-file","errorCode":null,"errorMessage":"usage: write <slug-or-target> <body-file>\n","messagePattern":"usage: write <slug-or-target> <body-file>\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/context/src/critique_storage.rs","lineNumber":465,"sourceCode":"        \"slug\" => {\n            let slug = slug_from_target(rest.first().map(String::as_str), &cwd);\n            match slug {\n                Some(s) => {\n                    io.out(&format!(\"{}\\n\", s));\n                    0\n                }\n                None => {\n                    io.err(\"no stable slug for input\\n\");\n                    1\n                }\n            }\n        }\n        \"write\" => {\n            let slug_arg = rest.first().map(String::as_str).unwrap_or(\"\");\n            let slug = coerce_slug(rest.first().map(String::as_str), &cwd);\n            let body_file = rest.get(1).filter(|s| !s.is_empty());\n            let (Some(slug), Some(body_file)) = (slug, body_file) else {\n                io.err(\"usage: write <slug-or-target> <body-file>\\n\");\n                return 1;\n            };\n            let raw = match std::fs::read(body_file) {\n                Ok(b) => String::from_utf8_lossy(&b).into_owned(),\n                Err(e) => {\n                    // JS: uncaught exception -> stack trace on stderr, exit 1\n                    io.err(&format!(\"{}\\n\", uncaught(&node_read_error(body_file, &e))));\n                    return 1;\n                }\n            };\n            let mut parsed_meta: Map<String, Value> = Map::new();\n            if let Some(m) = env.get(\"IMPECCABLE_CRITIQUE_META\").filter(|s| !s.is_empty()) {\n                if let Ok(Value::Object(o)) = serde_json::from_str::<Value>(m) {\n                    parsed_meta = o;\n                }\n            }\n            // JS #660: the helper, not caller metadata, owns the target\n            // fingerprint/identity. Drop any caller-supplied copies (preserving","sourceCodeStart":447,"sourceCodeEnd":483,"githubUrl":"https://github.com/pbakaus/impeccable/blob/2bc2879276c1f321a53c4ca99d3371e411329b52/crates/context/src/critique_storage.rs#L447-L483","documentation":"The critique-storage `write` subcommand requires two positional arguments: a slug-or-target and a body file to store. When either is missing or empty (`coerce_slug` returns None or the body-file argument is absent/empty), it prints this usage line and exits 1 without reading or writing anything.","triggerScenarios":"Running `write` with zero or one positional argument; passing an empty string as either argument; the slug argument is present but `coerce_slug` can't derive a stable slug from it (same coercion as the slug subcommand); the body-file argument is an empty string rather than a path.","commonSituations":"Shell variable expansion yielding empty args (`write \"$SLUG\" \"$FILE\"` with unset vars); forgetting the body file when piping output manually; copying usage from an older version of the tool with different argument order.","solutions":["Supply both positionals: `write <slug-or-target> <body-file>`.","Check shell variables are non-empty before invoking; quote paths.","Use a slug known to work (test it with the `slug` subcommand first).","Write the critique body to a file first, then pass its path as the second argument."],"exampleFix":"// before (FILE unset)\ncontext critique write my-app-web \"$FILE\"\n// usage: write <slug-or-target> <body-file>\n// after\ncontext critique write my-app-web ./critique.md","handlingStrategy":"validation","validationCode":"const [slug, bodyFile] = restArgs;\nif (!slug?.trim() || !bodyFile?.trim()) {\n  console.error('usage: write <slug-or-target> <body-file>');\n  process.exit(2);\n}\nif (!existsSync(bodyFile)) {\n  console.error(`body file not found: ${bodyFile}`);\n  process.exit(2);\n}","typeGuard":"function writeArgsValid(rest) {\n  return typeof rest?.[0] === 'string' && rest[0].trim().length > 0 &&\n         typeof rest?.[1] === 'string' && rest[1].trim().length > 0;\n}","tryCatchPattern":"const res = spawnSync('context', ['critique', 'write', slug, bodyFile], { encoding: 'utf8' });\nif (res.status !== 0 && res.stderr.startsWith('usage: write')) {\n  console.error('Both a slug-or-target and a body-file are required.');\n}","preventionTips":["Validate shell variables are non-empty before interpolating into the command.","Write the critique body to a file before invoking write; never rely on an in-flight pipe.","Pre-test the slug with the `slug` subcommand to confirm coercion works."],"tags":["cli","usage","missing-argument"],"backgroundTag":"missing-required-argument","analyzedSha":"2bc2879276c1f321a53c4ca99d3371e411329b52","analyzedAt":"2026-09-08T04:51:14.109Z","contentChangedAt":"2026-09-08T04:51:14.109Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}