gastownhall/beads · error

--deps target is empty

Error message

--deps target is empty

What it means

resolveDepSpecTargets validates every --deps spec's TargetID after whitespace trimming; an empty target (e.g. "blocks:" or an empty list element ",") yields this error. Empty targets can never resolve to an issue, so the CLI fails fast before any ID resolution or DB write.

Source

Thrown at cmd/bd/create_deps.go:115

}

// resolveDepSpecTargets rewrites each non-external TargetID through the same
// partial-ID resolution path as `bd dep add` (utils.ResolvePartialID).
//
// Without this, `bd create --deps discovered-from:8vezf` stores the bare
// token as depends_on_id, producing a dangling edge that `bd dep list` cannot
// see and that `bd dep remove … 8vezf` then mis-targets after resolving the
// good fully-qualified row (GH#5005).
func resolveDepSpecTargets(ctx context.Context, st storage.Storage, specs []domain.DependencySpec) ([]domain.DependencySpec, error) {
	if len(specs) == 0 {
		return specs, nil
	}
	out := make([]domain.DependencySpec, len(specs))
	for i, spec := range specs {
		out[i] = spec
		target := strings.TrimSpace(spec.TargetID)
		if target == "" {
			return nil, fmt.Errorf("--deps target is empty")
		}
		if strings.HasPrefix(target, "external:") {
			out[i].TargetID = target
			continue
		}
		resolved, err := utils.ResolvePartialID(ctx, st, target)
		if err != nil {
			return nil, fmt.Errorf("resolving --deps target %q: %w", target, err)
		}
		out[i].TargetID = resolved
	}
	return out, nil
}

func parseDepSpec(raw string) (domain.DependencySpec, error) {
	if !strings.Contains(raw, ":") {
		return domain.DependencySpec{
			Type:     types.DepBlocks,

View on GitHub (pinned to 71377f2769)

Solutions

  1. Fix the --deps argument so every spec has a non-empty target after the colon
  2. In scripts, guard the variable: skip the flag entirely if the dep ID variable is empty
  3. Trim and split the list before passing it, dropping empty segments

Example fix

// before
bd create "Task" --deps "blocks:$DEP_ID"   # DEP_ID empty -> '--deps target is empty'
// after
if [ -n "$DEP_ID" ]; then
  bd create "Task" --deps "blocks:$DEP_ID"
fi
Defensive patterns

Strategy: validation

Validate before calling

parts := strings.Split(depsFlag, ",")
for _, p := range parts {
    if strings.TrimSpace(strings.TrimPrefix(strings.TrimSpace(p), "")) == "" || strings.HasSuffix(strings.TrimSpace(p), ":") {
        return fmt.Errorf("empty --deps entry: %q", p)
    }
}

Prevention

When it happens

Trigger: `bd create ... --deps "blocks:"` (colon with no id), `--deps "bd-1,,bd-2"` (empty element from double comma), or `--deps ","` / trailing-comma style inputs parsed by parseDepSpecs into a spec with TargetID="".

Common situations: Shell scripts building the deps string with variables that are unset/empty (e.g. `--deps "blocks:$DEP_ID"` with $DEP_ID empty); copy-pasted lists with stray commas.

Related errors


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