{"record":{"id":"8e7b9c5ffe121070","repo":"jdx/mise","slug":"directive-requires-exactly-one-argument","errorCode":null,"errorMessage":"directive requires exactly one argument","messagePattern":"directive requires exactly one argument","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/task/workspace/go.rs","lineNumber":199,"sourceCode":"        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\");\n    }\n    Ok(value.to_string())\n}\n\nfn unescape_go_string(value: &str) -> Result<String> {\n    let mut characters = value.chars();\n    let mut unescaped = String::new();\n    while let Some(character) = characters.next() {\n        if character == '\"' {\n            bail!(\"unexpected interpreted Go string delimiter\");\n        }\n        if character != '\\\\' {\n            unescaped.push(character);\n            continue;\n        }\n        let escape = characters\n            .next()\n            .ok_or_else(|| eyre::eyre!(\"unterminated Go string escape\"))?;","sourceCodeStart":181,"sourceCodeEnd":217,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/task/workspace/go.rs#L181-L217","documentation":"For a plain (unquoted) directive argument, parse_argument requires the remaining text to be exactly one whitespace-delimited token. If it contains multiple tokens, the directive would have more than one argument, which module/use do not allow, so it bails with 'directive requires exactly one argument'.","triggerScenarios":"A `use` or `module` line in go.work/go.mod carries two or more unquoted space-separated tokens, e.g. `use ./a ./b` or trailing garbage after the path.","commonSituations":"Listing multiple directories on one use line (must be separate lines or a use block); stray trailing text left by a bad sed/regex edit; a comment not stripped properly leaving extra tokens.","solutions":["Split multiple directories onto separate `use` lines, or group them in a `use ( ... )` block.","Remove the extra token/trailing garbage from the line.","Quote the single value if it contains spaces (paths with spaces must be quoted, which also satisfies the parser)."],"exampleFix":"// before (go.work)\nuse ./a ./b\n\n// after\nuse (\n  ./a\n  ./b\n)","handlingStrategy":"validation","validationCode":"// shell\ngrep -nE '^[ \\t]*(use|module)[ \\t]+[^ (][^ ]*[ \\t]+[^ ]' go.work go.mod && { echo 'too many arguments on directive line'; exit 1; } || true","typeGuard":null,"tryCatchPattern":null,"preventionTips":["One directory per `use` line, or use a `use ( ... )` block for multiples","Paths with spaces must be quoted (\"my dir\"), not left bare","After scripted edits to go.work/go.mod, run `go work sync` / `go mod tidy` to catch syntax errors"],"tags":["go","parse-error","argument-count"],"backgroundTag":"invalid-argument-format","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"}