{"record":{"id":"8b22f33a235b5714","repo":"gastownhall/beads","slug":"add-label-id-must-not-be-empty","errorCode":null,"errorMessage":"add label: id must not be empty","messagePattern":"add label: id must not be empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/domain/label.go","lineNumber":61,"sourceCode":"}\n\ntype labelUseCaseImpl struct {\n\tlabelRepo LabelSQLRepository\n}\n\nvar _ LabelUseCase = (*labelUseCaseImpl)(nil)\n\nfunc (u *labelUseCaseImpl) AddLabel(ctx context.Context, issueID, label, actor string) error {\n\treturn u.add(ctx, issueID, label, actor, false)\n}\n\nfunc (u *labelUseCaseImpl) AddWispLabel(ctx context.Context, wispID, label, actor string) error {\n\treturn u.add(ctx, wispID, label, actor, true)\n}\n\nfunc (u *labelUseCaseImpl) add(ctx context.Context, id, label, actor string, useWisp bool) error {\n\tif id == \"\" {\n\t\treturn fmt.Errorf(\"add label: id must not be empty\")\n\t}\n\tif label == \"\" {\n\t\treturn fmt.Errorf(\"add label: label must not be empty\")\n\t}\n\tif err := u.labelRepo.Insert(ctx, id, label, actor, LabelOpts{UseWispsTable: useWisp}); err != nil {\n\t\treturn fmt.Errorf(\"add label %s/%s: %w\", id, label, err)\n\t}\n\treturn nil\n}\n\nfunc (u *labelUseCaseImpl) RemoveLabel(ctx context.Context, issueID, label, actor string) error {\n\treturn u.remove(ctx, issueID, label, actor, false)\n}\n\nfunc (u *labelUseCaseImpl) RemoveWispLabel(ctx context.Context, wispID, label, actor string) error {\n\treturn u.remove(ctx, wispID, label, actor, true)\n}\n","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/domain/label.go#L43-L79","documentation":"A guard error from the label use case's internal add(): it rejects adding a label when the target issue/wisp ID is the empty string. Called by AddLabel and AddWispLabel before any repository write happens, so nothing is persisted.","triggerScenarios":"Calling AddLabel(ctx, \"\", label, actor) or AddWispLabel(ctx, \"\", label, actor) — i.e. the ID argument is \"\", typically because an upstream lookup returned no issue or a variable was never populated.","commonSituations":"Scripting bd commands with variables that expand to empty (missing issue key from shell var); parsing a file where the ID column was blank; calling the Go API directly in tests/tools without resolving an ID first.","solutions":["Resolve and pass a valid issue ID (e.g. bd-123) before calling AddLabel/AddWispLabel.","Check upstream code that produced the ID — a failed lookup or parse often yields an empty string.","In scripts, quote/verify shell variables: ensure $ISSUE_ID is non-empty before invoking bd.","If the record may not exist, fetch it first and skip the label operation when the ID is absent."],"exampleFix":"// before\nlabelUC.AddLabel(ctx, issueID, \"priority:high\", actor) // issueID == \"\"\n\n// after\nif issueID == \"\" {\n    return fmt.Errorf(\"cannot add label: issue ID is empty\")\n}\nlabelUC.AddLabel(ctx, issueID, \"priority:high\", actor)","handlingStrategy":"validation","validationCode":"func addLabelSafe(ctx context.Context, uc LabelUseCase, id, label, actor string) error {\n    if strings.TrimSpace(id) == \"\" {\n        return errors.New(\"add label: issue ID is required\")\n    }\n    return uc.AddLabel(ctx, id, label, actor)\n}","typeGuard":"func hasIssueID(id string) bool { return strings.TrimSpace(id) != \"\" }","tryCatchPattern":"if err := uc.AddLabel(ctx, id, label, actor); err != nil {\n    if strings.Contains(err.Error(), \"id must not be empty\") {\n        return fmt.Errorf(\"caller bug: unresolved issue ID\")\n    }\n    return err\n}","preventionTips":["Always resolve an issue via a lookup before labeling; propagate lookup errors","Validate IDs at CLI/tool entry points, not deep in the call stack","In shell scripts, guard: [ -n \"$ISSUE_ID\" ] || exit 1","Make unresolved-ID a typed error in your own layer so it can't silently become \"\""],"tags":["validation","labels","argument-error"],"backgroundTag":"missing-required-argument","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}