gastownhall/beads · error

cannot combine %s

Error message

cannot combine %s

What it means

This error is returned by textFromSources in cmd/bd/flags.go when a command is given more than one mutually exclusive text source at once (e.g. --stdin together with --file, or either combined with positional text args). The names of all provided sources are joined with ' with ' in the message. These sources are deliberately exclusive because only one can supply the command's text input.

Source

Thrown at cmd/bd/flags.go:286

	if src.flagSet || src.flagText != "" {
		sources = append(sources, source{src.flagName, func() (string, error) {
			return src.flagText, nil
		}})
	}

	provided = len(sources) > 0 || len(src.positional) > 0
	switch len(sources) {
	case 0:
		return "", provided, nil
	case 1:
		text, err = sources[0].resolve()
		return text, provided, err
	default:
		names := make([]string, len(sources))
		for i, s := range sources {
			names[i] = s.name
		}
		return "", provided, fmt.Errorf("cannot combine %s", strings.Join(names, " with "))
	}
}

// cmdTextSources builds textSources from a command's --stdin and --file
// flags (either may be unregistered) plus its positional text args. Callers
// with a command-specific text flag fill in flagText/flagName themselves.
func cmdTextSources(cmd *cobra.Command, positional []string) textSources {
	src := textSources{positional: positional}
	if stdinFlag, _ := cmd.Flags().GetBool("stdin"); stdinFlag {
		src.stdin = os.Stdin
	}
	src.filePath, _ = cmd.Flags().GetString("file")
	return src
}

// registerTextSourceFlags registers the shared text-source flags — --stdin
// and --file, read back by name in cmdTextSources — and marks them mutually
// exclusive with each other and with any command-specific text flags (e.g.

View on GitHub (pinned to 71377f2769)

Solutions

  1. Remove all but one text source: keep positional text OR --stdin OR --file.
  2. If scripting, conditionally add --stdin only when no positional text or --file is passed.
  3. Review the command's help output to see which text input flags are supported and exclusive.

Example fix

// before
echo "desc" | bd create "title" --stdin --file notes.txt
// after
echo "desc" | bd create "title" --stdin
Defensive patterns

Strategy: validation

Validate before calling

// shell: ensure only one text source
sources=0
[ -n "$POSITIONAL" ] && sources=$((sources+1))
[ $USE_STDIN -eq 1 ] && sources=$((sources+1))
[ -n "$FILE_FLAG" ] && sources=$((sources+1))
[ $sources -le 1 ] || { echo "cannot combine text sources" >&2; exit 1; }

Prevention

When it happens

Trigger: Invoking a bd command with two or more text sources simultaneously, e.g. `bd create "text" --stdin`, `bd create "text" --file f.txt`, or `bd ... --stdin --file f.txt`. textFromSources hits the default branch when len(sources) > 1.

Common situations: Scripted invocations that pass both a heredoc/piped stdin and a positional description; shell wrappers that append --stdin unconditionally while the user also supplied --file or positional text; copy-pasted commands accumulating both flags.

Related errors


AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30). Data as JSON: /api/errors/75999844fd1622c2. Report an issue: GitHub.