{"record":{"id":"d25b5c59d533b1a8","repo":"multica-ai/multica","slug":"s-file-q-empty-contents-s","errorCode":null,"errorMessage":"--%s-file %q: empty contents%s","messagePattern":"--(.+?)-file %q: empty contents(.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/cmd/multica/cmd_agent.go","lineNumber":1421,"sourceCode":"\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\n}\n\nfunc strVal(m map[string]any, key string) string {\n\tv, ok := m[key]\n\tif !ok || v == nil {\n\t\treturn \"\"\n\t}\n\treturn fmt.Sprintf(\"%v\", v)\n}\n","sourceCodeStart":1403,"sourceCodeEnd":1439,"githubUrl":"https://github.com/multica-ai/multica/blob/2c0912b6ec764b373d44eeea1e80f0d9f11ab417/server/cmd/multica/cmd_agent.go#L1403-L1439","documentation":"Thrown when --<prefix>-file points to a file that is read successfully but contains only whitespace. Empty contents are rejected as a probable mistake rather than interpreted as a clear; the message names the offending path and, where the flag supports it, hints to pass 'null' to clear. Purely client-side validation before the API call.","triggerScenarios":"`multica agent update <id> --mcp-config-file empty.json` where empty.json is 0 bytes or only newlines/spaces; a template render that produced no output; a truncated download.","commonSituations":"Helm/envsubst templates that render to nothing when a value is missing; an empty file committed by mistake; a partially written file after a crashed generator.","solutions":["Put a real JSON object in the file: echo '{\"servers\": {}}' > cfg.json","To clear the field, write the literal null into the file (echo null > cfg.json) when the flag allows it","Validate files before use: test -s cfg.json && jq -e 'type == \"object\"' cfg.json"],"exampleFix":"# before\n: > cfg.json && multica agent update <id> --mcp-config-file cfg.json\n# after\nprintf '%s\\n' '{\"servers\": {}}' > cfg.json && multica agent update <id> --mcp-config-file cfg.json","handlingStrategy":"validation","validationCode":"test -s \"$CFG_FILE\" && jq -e 'type == \"object\"' \"$CFG_FILE\" >/dev/null || { echo \"invalid config file\" >&2; exit 1; }\nmultica agent update <id> --mcp-config-file \"$CFG_FILE\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Lint rendered templates with jq in CI so empty renders fail the build, not the CLI call","Write config files atomically (tmp + mv) so truncated files never get read","Use test -s as a cheap non-empty guard before any file flag"],"tags":["cli","filesystem","validation","go"],"backgroundTag":null,"analyzedSha":"2c0912b6ec764b373d44eeea1e80f0d9f11ab417","analyzedAt":"2026-08-15T13:25:18.241Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}