gastownhall/beads · error

get labels: id must not be empty

Error message

get labels: id must not be empty

What it means

Returned by list (GetLabels / GetWispLabels) when the ID is empty. The use case rejects empty IDs before querying the repository. Note the error for a valid-but-failing read uses a slightly different format ('get labels %s'), so this exact message always means the ID string itself was empty.

Source

Thrown at internal/storage/domain/label.go:193

			if err := u.labelRepo.Insert(ctx, id, l, actor, opts); err != nil {
				return fmt.Errorf("set labels: add %s: %w", l, err)
			}
		}
	}
	return nil
}

func (u *labelUseCaseImpl) GetLabels(ctx context.Context, issueID string) ([]string, error) {
	return u.list(ctx, issueID, false)
}

func (u *labelUseCaseImpl) GetWispLabels(ctx context.Context, wispID string) ([]string, error) {
	return u.list(ctx, wispID, true)
}

func (u *labelUseCaseImpl) list(ctx context.Context, id string, useWisp bool) ([]string, error) {
	if id == "" {
		return nil, fmt.Errorf("get labels: id must not be empty")
	}
	out, err := u.labelRepo.List(ctx, id, LabelOpts{UseWispsTable: useWisp})
	if err != nil {
		return nil, fmt.Errorf("get labels %s: %w", id, err)
	}
	return out, nil
}

func (u *labelUseCaseImpl) GetLabelsForIssues(ctx context.Context, issueIDs []string) (map[string][]string, error) {
	return u.listBulk(ctx, issueIDs, false)
}

func (u *labelUseCaseImpl) GetLabelsForWisps(ctx context.Context, wispIDs []string) (map[string][]string, error) {
	return u.listBulk(ctx, wispIDs, true)
}

func (u *labelUseCaseImpl) listBulk(ctx context.Context, ids []string, useWisp bool) (map[string][]string, error) {
	if len(ids) == 0 {

View on GitHub (pinned to 71377f2769)

Solutions

  1. Verify the ID was captured from CreateIssue/lookup before calling GetLabels
  2. Guard with a non-empty check and skip or error per record
  3. Fix the upstream producer of the empty ID
  4. Use GetWispLabels for wisps, passing the wisp ID

Example fix

// before
labels, _ := store.GetLabels(ctx, record.ID) // record.ID empty
// after
if record.ID == "" { continue }
labels, err := store.GetLabels(ctx, record.ID)
Defensive patterns

Strategy: validation

Validate before calling

if id == "" {
	return nil, fmt.Errorf("cannot get labels: id is empty")
}
labels, err := store.GetLabels(ctx, id)

Prevention

When it happens

Trigger: GetLabels(ctx, "") or GetWispLabels(ctx, ""); reading IDs from JSON/YAML where the field was omitted; calling before an issue was created and its ID captured.

Common situations: Template generators rendering label views for unset IDs; dashboards iterating over records where some entries lack IDs; wiring mistakes passing the wrong struct field.

Related errors


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