{"record":{"id":"1a6828dd87c3e4fd","repo":"multica-ai/multica","slug":"file-content-for-s-is-empty","errorCode":null,"errorMessage":"file content for --%s is empty","messagePattern":"file content for --(.+?) is empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/cmd/multica/cmd_issue.go","lineNumber":82,"sourceCode":"\t\t\treturn \"\", false, fmt.Errorf(\"read stdin for --%s: %w\", stdinFlag, err)\n\t\t}\n\t\tbody := strings.TrimSuffix(string(data), \"\\n\")\n\t\tif body == \"\" {\n\t\t\treturn \"\", false, fmt.Errorf(\"stdin content for --%s is empty\", stdinFlag)\n\t\t}\n\t\treturn body, true, nil\n\t}\n\tif filePath != \"\" {\n\t\tif err := ensureFileFlagWithinWorkdir(cmd, fileFlag, flagName, filePath); err != nil {\n\t\t\treturn \"\", false, err\n\t\t}\n\t\tdata, err := os.ReadFile(filePath)\n\t\tif err != nil {\n\t\t\treturn \"\", false, fmt.Errorf(\"read file for --%s: %w\", fileFlag, err)\n\t\t}\n\t\tbody := strings.TrimSuffix(string(data), \"\\n\")\n\t\tif body == \"\" {\n\t\t\treturn \"\", false, fmt.Errorf(\"file content for --%s is empty\", fileFlag)\n\t\t}\n\t\treturn body, true, nil\n\t}\n\tif inline == \"\" {\n\t\treturn \"\", false, nil\n\t}\n\treturn util.UnescapeBackslashEscapes(inline), true, nil\n}\n\n// ensureFileFlagWithinWorkdir fails closed when a --<name>-file path resolves\n// outside the current working directory, unless --allow-external-file is set.\n//\n// Agent task workdirs are isolated per profile and per task; machine-shared\n// scratch paths like /tmp are not. MUL-4252 traced a cross-environment context\n// leak to exactly this gap: a quick-create run wrote its description to a fixed\n// /tmp/desc.md, the write silently failed because a *different* environment's\n// run had left a stale file there minutes earlier, and --description-file then\n// fed that stale content into the new issue. Requiring the file to live under","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/multica-ai/multica/blob/2c0912b6ec764b373d44eeea1e80f0d9f11ab417/server/cmd/multica/cmd_issue.go#L64-L100","documentation":"The CLI was given a --description-file / --content-file style flag whose target file exists and is readable, but after trimming a single trailing newline its content is empty. The CLI refuses to substitute empty content for the flag because that would silently wipe or no-op the field. This is a fail-fast guard so an empty file is reported instead of silently posting an empty description.","triggerScenarios":"Running `multica issue create --description-file <path>` (or any *-file flag handled by this helper) where the file is 0 bytes or contains only a single newline. The path must already pass the workdir guard and os.ReadFile, so the file exists and is readable but body == \"\" after strings.TrimSuffix(data, \"\\n\").","commonSituations":"Agent or script pipelines that write a description to a temp file and the upstream generator (editor, jq, another command) produced empty output; a heredoc that failed to capture anything; a truncated file from a killed process; a file containing only a blank line.","solutions":["Inspect the file (wc -c / cat -A) and fix the upstream step that was supposed to write the description so it produces real content.","If the empty file is itself unexpected, regenerate it and re-run the command.","If you intentionally have no content, drop the --*-file flag entirely instead of pointing it at an empty file.","For trivial one-line content, use the inline flag (e.g. --description \"text\") instead of a file."],"exampleFix":"# before\nprintf '' > desc.md\nmultica issue create --title \"Fix login\" --description-file desc.md\n# after\nprintf 'Login fails when session expires.' > desc.md\nmultica issue create --title \"Fix login\" --description-file desc.md","handlingStrategy":"validation","validationCode":"# before invoking:\n[ -s \"$DESC_FILE\" ] || { echo \"description file empty: $DESC_FILE\" >&2; exit 1; }\n# -s is true only for non-empty files; also catches the missing-file case early","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Generate content files with set -euo pipefail so a failed generator aborts before the CLI runs.","Never point --*-file at a file you haven't just written in the same script.","Prefer inline --description for short content; reserve file flags for multi-line bodies."],"tags":["cli","file-validation","issue-create"],"backgroundTag":null,"analyzedSha":"2c0912b6ec764b373d44eeea1e80f0d9f11ab417","analyzedAt":"2026-08-15T13:25:18.241Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}