{"record":{"id":"511926d6d3b066b4","repo":"gastownhall/beads","slug":"s-cannot-be-empty","errorCode":null,"errorMessage":"%s cannot be empty","messagePattern":"(.+?) cannot be empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/flags.go","lineNumber":327,"sourceCode":"\tcmd.Flags().String(\"file\", \"\", \"Read \"+noun+\" from file\")\n\tcmd.MarkFlagsMutuallyExclusive(append([]string{\"stdin\", \"file\"}, textFlags...)...)\n}\n\n// requireTextFromSources resolves body text like textFromSources and owns the\n// shared empty-text policy: text from an explicit source must be non-blank\n// (\"<noun> cannot be empty\"), and with no source at all the error lists the\n// command's accepted sources via hint (e.g. \"use positional args, --stdin, or\n// --file\").\nfunc requireTextFromSources(noun, hint string, src textSources) (string, error) {\n\ttext, provided, err := textFromSources(src)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tif strings.TrimSpace(text) != \"\" {\n\t\treturn text, nil\n\t}\n\tif provided {\n\t\treturn \"\", fmt.Errorf(\"%s cannot be empty\", noun)\n\t}\n\treturn \"\", fmt.Errorf(\"no %s provided (%s)\", noun, hint)\n}\n\n// registerPriorityFlag registers the priority flag with a specific default value.\nfunc registerPriorityFlag(cmd *cobra.Command, defaultVal string) {\n\tcmd.Flags().StringP(\"priority\", \"p\", defaultVal, \"Priority (0-4 or P0-P4, 0=highest)\")\n}\n","sourceCodeStart":309,"sourceCodeEnd":336,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/flags.go#L309-L336","documentation":"requireTextFromSources in cmd/bd/flags.go collects text from the command's text sources and requires it to be non-blank. When at least one source was provided (provided == true) but the resulting text is empty or whitespace-only after TrimSpace, it fails with '<noun> cannot be empty'. This distinguishes 'you passed a source but it contained nothing' from 'you passed no source at all' (error 613).","triggerScenarios":"Calling a command with --stdin or --file (or positional text) where the supplied content is empty or only whitespace, e.g. `echo \"\" | bd create --stdin`, or an empty --file, or passing \"\" as positional text.","commonSituations":"A file that exists but is empty or contains only newlines; a pipeline producing no output (grep with no matches piped into --stdin); a variable in a script that was unset/empty; passing \"\" as an argument accidentally via shell variable expansion.","solutions":["Provide actual non-whitespace content for the text source.","Check that the --file passed contains the expected text (wc -c file).","In scripts, verify the variable or upstream command output is non-empty before invoking bd.","If no content exists yet, omit the flag so the command fails with the clearer 'no <noun> provided' message or prompts appropriately."],"exampleFix":"// before\nEMPTY=\"\"\nbd create \"$EMPTY\"            # \"text cannot be empty\"\n// after\nif [ -n \"$DESC\" ]; then bd create \"$DESC\"; fi","handlingStrategy":"validation","validationCode":"// shell: reject empty input before invoking\nDESC=$(cat notes.txt)\n[ -n \"$(echo \"$DESC\" | tr -d '[:space:]')\" ] || { echo \"description is empty\" >&2; exit 1; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Trim and check text content before passing it to --stdin/--file.","Check files with [ -s file ] to ensure they are non-empty.","Guard pipelines: fail early if the producing command outputs nothing.","Quote and default shell variables to catch unset/empty cases."],"tags":["cli","validation","empty-input"],"backgroundTag":"empty-required-input","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}