{"record":{"id":"14951269e4d2944f","repo":"multica-ai/multica","slug":"invalid-s-w","errorCode":null,"errorMessage":"invalid %s: %w","messagePattern":"invalid (.+?): %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/internal/daemon/config.go","lineNumber":674,"sourceCode":"\tout := make([]string, 0, len(parts))\n\tfor _, p := range parts {\n\t\tp = strings.TrimSpace(p)\n\t\tif p == \"\" || strings.ContainsAny(p, \"/\\\\\") {\n\t\t\tcontinue\n\t\t}\n\t\tout = append(out, p)\n\t}\n\treturn out\n}\n\nfunc shellArgsFromEnv(name string) ([]string, error) {\n\traw := strings.TrimSpace(os.Getenv(name))\n\tif raw == \"\" {\n\t\treturn nil, nil\n\t}\n\targs, err := shellwords.Parse(raw)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"invalid %s: %w\", name, err)\n\t}\n\treturn args, nil\n}\n\n// resolveAgentExecutablePath returns the executable entry point the daemon\n// should keep for an agent command. Bare command names are pinned to the path\n// resolved during startup so later PATH changes cannot redirect task launches.\n// Ordinary executables are pinned to their concrete target; entrypoints owned\n// by a name-dispatching shim keep the command name the manager needs to select\n// the right package (see discoveredExecutablePath).\n// On Windows this deliberately keeps the stable discovered junction path;\n// resolveAgentEntryWithHeal follows it for each launch so installer upgrades\n// that retarget a still-live junction take effect without a daemon restart.\n// When ~/.multica/hooks shadows a real agent binary, skip that hooks directory:\n// previously generated hook wrappers can execute the same command name and\n// recurse forever if the daemon records or launches the wrapper.\nfunc resolveAgentExecutablePath(cmd string) (string, error) {\n\tresolved, err := exec.LookPath(cmd)","sourceCodeStart":656,"sourceCodeEnd":692,"githubUrl":"https://github.com/multica-ai/multica/blob/2c0912b6ec764b373d44eeea1e80f0d9f11ab417/server/internal/daemon/config.go#L656-L692","documentation":"shellArgsFromEnv parses agent-argument env vars (MULTICA_CLAUDE_ARGS, MULTICA_CODEX_ARGS, MULTICA_CODEBUDDY_ARGS, ...) with shellwords; unbalanced quotes, a trailing backslash, or other shell-syntax errors make Parse return an error, which is wrapped with the offending variable's name. The value is treated as a shell command line, not a raw string.","triggerScenarios":"Setting MULTICA_CLAUDE_ARGS='--model \"opus' (unclosed quote) or MULTICA_CODEX_ARGS='--flag value\\' (trailing escape). Any of the *ARGS env vars with invalid shell word syntax fails daemon startup at config load.","commonSituations":"Quoting mistakes when nesting quotes ('--prompt \"say \\\"hi\\\"\"'), Windows users copying cmd.exe syntax (%VAR% or doubled quotes) into a POSIX-style shellwords value, trailing backslashes from path arguments.","solutions":["Balance all quotes in the env value: MULTICA_CLAUDE_ARGS='--model \"opus-4\" --verbose'","Escape literal quotes as \\\" and avoid trailing backslashes; wrap Windows paths in quotes ('\"C:\\path\"')","After fixing, restart the daemon — config is only read at startup"],"exampleFix":"# before\nexport MULTICA_CLAUDE_ARGS=\"--model \\\"opus-4 --verbose\"   # unbalanced quotes\n# after\nexport MULTICA_CLAUDE_ARGS=\"--model opus-4 --verbose\"","handlingStrategy":"validation","validationCode":"// Dry-run the shellwords parse before handing the env to the daemon.\nfor _, name := range []string{\"MULTICA_CLAUDE_ARGS\", \"MULTICA_CODEX_ARGS\", \"MULTICA_CODEBUDDY_ARGS\"} {\n    if raw := strings.TrimSpace(os.Getenv(name)); raw != \"\" {\n        if _, err := shellwords.Parse(raw); err != nil {\n            return fmt.Errorf(\"%s has invalid shell syntax: %w\", name, err)\n        }\n    }\n}","typeGuard":null,"tryCatchPattern":"Catch at config load; parse the env value with shellwords yourself in a CLI lint step ('multica config check') to surface quoting errors before daemon start.","preventionTips":["Keep args values simple: space-separated flags, quote multi-word values once","Test quoting with 'echo $MULTICA_X_ARGS | xargs -n1 echo' style checks","Avoid Windows-style %VAR% and doubled quotes in these env vars"],"tags":["daemon","config","shell-args","env-var","quoting"],"backgroundTag":null,"analyzedSha":"2c0912b6ec764b373d44eeea1e80f0d9f11ab417","analyzedAt":"2026-08-15T13:25:18.241Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}