{"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":"eyre::Report","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/6f52dcdf99e282ef7a7db68c81301fa4618d0f79/src/task/workspace/go.rs#L181-L217","documentation":"For unquoted arguments, parse_argument requires exactly one whitespace-separated token (value.split_whitespace().count() != 1 fails). A use or module directive carrying two or more bare words cannot name a single path, so parsing aborts.","triggerScenarios":"go.work line `use ./api ./worker` (two directories on one directive); a go.mod `module example.com/foo extra`; entries where a trailing unquoted comment marker survived (e.g. `use ./api # note` after comment stripping leaves two tokens if '#' was not a // comment).","commonSituations":"Trying to list multiple modules on one line the way array syntax allows elsewhere; pasting a path plus annotation; converting from another format that joined entries with spaces.","solutions":["Split into one directive per entry: `use ./api` then `use ./worker` (or one per line inside a use (...) block)","Use Go's block form for many entries","If a path contains spaces, quote it as one interpreted string \\\"./my dir\\\""],"exampleFix":"# before (go.work)\nuse ./api ./worker\n\n# after\nuse (\n    ./api\n    ./worker\n)","handlingStrategy":"validation","validationCode":"fn is_single_token(token: &str) -> bool {\n    token.starts_with('\"') || token.starts_with('`') || token.split_whitespace().count() == 1\n}\n\nfor arg in directive_arguments { assert!(is_single_token(arg)); }","typeGuard":"fn is_one_directive_argument(token: &str) -> bool {\n    token.starts_with('\"') || token.starts_with('`') || token.split_whitespace().count() == 1\n}","tryCatchPattern":"Err(report) if report.to_string().contains(\"requires exactly one argument\") => {\n    // split multi-word directives into one use per token and re-parse\n    for word in arguments.split_whitespace() { push_use(word); }\n}","preventionTips":["One directory per use directive; use the use (...) block for many entries","Quote paths containing spaces with interpreted strings","Wrap go.work edits with `go work sync` validation in CI"],"tags":["go","go-work","go-mod","parse","syntax"],"backgroundTag":"too-many-arguments","analyzedSha":"6f52dcdf99e282ef7a7db68c81301fa4618d0f79","analyzedAt":"2026-08-22T10:14:23.840Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}