{"record":{"id":"f89d045faf541071","repo":"jdx/mise","slug":"directive-requires-one-argument","errorCode":null,"errorMessage":"directive requires one argument","messagePattern":"directive requires one argument","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/task/workspace/go.rs","lineNumber":181,"sourceCode":"        if module_path.replace(parsed).is_some() {\n            bail!(\"Go module metadata contains multiple module directives\");\n        }\n    }\n\n    module_path.ok_or_else(|| eyre::eyre!(\"Go module metadata is missing a module directive\"))\n}\n\nfn directive_arguments<'a>(line: &'a str, directive: &str) -> Option<&'a str> {\n    let rest = line.strip_prefix(directive)?;\n    if !rest.starts_with(char::is_whitespace) {\n        return None;\n    }\n    Some(rest.trim())\n}\n\nfn parse_argument(value: &str) -> Result<String> {\n    if value.is_empty() {\n        bail!(\"directive requires one argument\");\n    }\n    if let Some(value) = value.strip_prefix('\"') {\n        let Some(value) = value.strip_suffix('\"') else {\n            bail!(\"unterminated interpreted Go string\");\n        };\n        return unescape_go_string(value);\n    }\n    if let Some(value) = value.strip_prefix('`') {\n        let Some(value) = value.strip_suffix('`') else {\n            bail!(\"unterminated raw Go string\");\n        };\n        if value.contains('`') {\n            bail!(\"unexpected raw Go string delimiter\");\n        }\n        return Ok(value.to_string());\n    }\n    if value.split_whitespace().count() != 1 {\n        bail!(\"directive requires exactly one argument\");","sourceCodeStart":163,"sourceCodeEnd":199,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/task/workspace/go.rs#L163-L199","documentation":"parse_argument parses the argument of a Go directive (module, use) in go.work/go.mod. An empty argument — nothing after the directive keyword, or only whitespace — cannot name a directory or module path, so it bails with 'directive requires one argument'.","triggerScenarios":"go.work has `use` with no argument, or inside a use block an empty/whitespace-only line survives comment stripping and trimming, then reaches parse_argument; same for a bare `module` line in go.mod.","commonSituations":"Editing go.work and leaving a dangling `use` line; a commented-out value (`use // ./x`) leaving only the keyword; generated files with blank lines inside a use block (blank lines are skipped, but keyword-only lines are not).","solutions":["Give the directive an argument: `use ./dir` or `module example.com/m`.","Delete the empty directive line entirely.","Wrap multiple entries in a use block properly (`use ( ... )`) instead of repeating a bare `use`."],"exampleFix":"// before (go.work)\nuse\n\n// after\nuse ./services/api","handlingStrategy":"validation","validationCode":"// shell\nawk '$1==\"use\" && NF<2 && $0 !~ /\\($/ && $0 !~ /^use[ \\t]*\\($/ {print \"bare directive: \" $0; bad=1} END{exit bad}' go.work","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always give `use`/`module` a value on the same line","If you comment out a directive, comment the whole line (`// use ./x`), not just the value","Regenerate files with go CLI rather than hand-stripping lines"],"tags":["go","parse-error","missing-argument"],"backgroundTag":"missing-required-argument","analyzedSha":"533346cc374382b41ec5ff70536252b2e96e725c","analyzedAt":"2026-09-17T13:35:38.149Z","contentChangedAt":"2026-09-17T13:35:38.149Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}