{"record":{"id":"4e0f5e33b621c6c8","repo":"multica-ai/multica","slug":"s-file-path-must-not-be-empty","errorCode":null,"errorMessage":"--%s-file: path must not be empty","messagePattern":"--(.+?)-file: path must not be empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/cmd/multica/cmd_agent.go","lineNumber":1411,"sourceCode":"\tif allowNull {\n\t\tclearHint = \"; pass 'null' to clear\"\n\t}\n\tvar raw string\n\tswitch {\n\tcase inline:\n\t\traw, _ = cmd.Flags().GetString(prefix)\n\tcase fromStdin:\n\t\tbuf, err := io.ReadAll(cmd.InOrStdin())\n\t\tif err != nil {\n\t\t\treturn nil, false, fmt.Errorf(\"read --%s-stdin: %w\", prefix, err)\n\t\t}\n\t\traw = string(buf)\n\t\tif strings.TrimSpace(raw) == \"\" {\n\t\t\treturn nil, false, fmt.Errorf(\"--%s-stdin: empty input%s\", prefix, clearHint)\n\t\t}\n\tcase fromFile:\n\t\tif filePath == \"\" {\n\t\t\treturn nil, false, fmt.Errorf(\"--%s-file: path must not be empty\", prefix)\n\t\t}\n\t\tbuf, err := os.ReadFile(filePath)\n\t\tif err != nil {\n\t\t\t// Filesystem errors may include the path but not the contents —\n\t\t\t// safe to surface via %w.\n\t\t\treturn nil, false, fmt.Errorf(\"read --%s-file: %w\", prefix, err)\n\t\t}\n\t\traw = string(buf)\n\t\tif strings.TrimSpace(raw) == \"\" {\n\t\t\treturn nil, false, fmt.Errorf(\"--%s-file %q: empty contents%s\", prefix, filePath, clearHint)\n\t\t}\n\t}\n\n\tmc, err := parseMcpJSONObject(\"--\"+prefix, raw, allowNull)\n\tif err != nil {\n\t\treturn nil, false, err\n\t}\n\treturn mc, true, nil","sourceCodeStart":1393,"sourceCodeEnd":1429,"githubUrl":"https://github.com/multica-ai/multica/blob/2c0912b6ec764b373d44eeea1e80f0d9f11ab417/server/cmd/multica/cmd_agent.go#L1393-L1429","documentation":"Thrown when --<prefix>-file is set but its value is the empty string. The CLI checks the path before attempting os.ReadFile, so no filesystem access happens. Almost always caused by an empty shell variable being expanded into the flag.","triggerScenarios":"`multica agent update <id> --mcp-config-file \"$CFG_FILE\"` where CFG_FILE is unset/empty; scripts with `--mcp-config-file=${CFG:-}` patterns; flag value consisting only of nothing after shell expansion.","commonSituations":"Optional configuration variable never initialized; a CI job that only sets the variable on one branch of the pipeline; typo'd variable name that expands to empty.","solutions":["Set the variable or pass a real path: --mcp-config-file ./config/mcp.json","Guard in the script: only pass the flag when the variable is non-empty","If the field should be cleared, use the null sentinel on the inline/stdin variants instead of an empty file flag"],"exampleFix":"# before\nmultica agent update <id> --mcp-config-file \"$MCP_FILE\"  # MCP_FILE=\"\"\n# after\nMCP_FILE=./config/mcp.json\nmultica agent update <id> --mcp-config-file \"$MCP_FILE\"","handlingStrategy":"validation","validationCode":"if [ -n \"${CFG_FILE:-}\" ]; then\n  multica agent update <id> --mcp-config-file \"$CFG_FILE\"\nelse\n  multica agent update <id>\nfi","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use set -u so empty variables abort the script","Build flag arrays conditionally: [ -n \"$VAR\" ] && args+=(--mcp-config-file \"$VAR\")","Never pass ${VAR:-} style defaults to path flags"],"tags":["cli","flags","validation","shell","go"],"backgroundTag":null,"analyzedSha":"2c0912b6ec764b373d44eeea1e80f0d9f11ab417","analyzedAt":"2026-08-15T13:25:18.241Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}