{"record":{"id":"25e3241b1a14143f","repo":"gastownhall/beads","slug":"memory-content-cannot-be-empty","errorCode":null,"errorMessage":"memory content cannot be empty","messagePattern":"memory content cannot be empty","errorType":"validation","errorClass":"memoryops.ErrValidation","httpStatus":null,"severity":"warning","filePath":"internal/memoryapi/memoryapi.go","lineNumber":82,"sourceCode":"\tslug := strings.Join(parts, \"-\")\n\n\tif len(slug) > 60 {\n\t\tslug = slug[:60]\n\t\t// A cap that landed mid-word must not leave the key ending in the\n\t\t// separator.\n\t\tslug = strings.TrimRight(slug, \"-\")\n\t}\n\treturn slug\n}\n\n// ValidateContent checks the content a caller wants to remember.\n//\n// The prose is `bd remember`'s, preserved: it is the sentence agents have been\n// reading since the command shipped, and the sentinel is what code classifies\n// on.\nfunc ValidateContent(content string) error {\n\tif strings.TrimSpace(content) == \"\" {\n\t\treturn fmt.Errorf(\"%w: memory content cannot be empty\", memoryops.ErrValidation)\n\t}\n\treturn nil\n}\n\n// ValidateKey checks a key a caller wants to read or remove, and returns it\n// UNCHANGED.\n//\n// Unchanged is the whole point: `bd remember --key` accepts any string, so a\n// key differing from another only by surrounding space is a key someone may\n// genuinely hold, and trimming it here would answer a different question from\n// the one asked. The only rule is that a key has to name something.\nfunc ValidateKey(key string) (string, error) {\n\tif strings.TrimSpace(key) == \"\" {\n\t\treturn \"\", fmt.Errorf(\"%w: memory key must not be empty\", memoryops.ErrValidation)\n\t}\n\treturn key, nil\n}\n","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/memoryapi/memoryapi.go#L64-L100","documentation":"ValidateContent rejects memory content that is empty or only whitespace. A memory with no content cannot be stored or used to derive a key, so the memory API fails fast with a memoryops.ErrValidation-wrapped error. This is bd remember's input validation gate.","triggerScenarios":"Calling ValidateContent(\"\") or with a whitespace-only string; calling bd remember with an empty message; ResolveKey receiving content that fails this check.","commonSituations":"Shell variable holding the memory text is unset/empty (e.g. bd remember \"$NOTE\" with NOTE empty); piping empty stdin into remember; script constructing an empty memory string.","solutions":["Pass non-empty text to bd remember / ValidateContent.","Check the shell variable or stdin source actually contains the intended content.","Handle the error by prompting for or defaulting the memory text before storing."],"exampleFix":"// before\nif err := memoryapi.ValidateContent(note); err != nil { ... } // note == \"\"\n// after\nif strings.TrimSpace(note) == \"\" {\n    return fmt.Errorf(\"nothing to remember: provide content\")\n}\nif err := memoryapi.ValidateContent(note); err != nil { ... }","handlingStrategy":"validation","validationCode":"if strings.TrimSpace(content) == \"\" {\n    return fmt.Errorf(\"nothing to remember: content is empty\")\n}","typeGuard":"func hasMemoryContent(s string) bool { return strings.TrimSpace(s) != \"\" }","tryCatchPattern":"if err := memoryapi.ValidateContent(content); err != nil {\n    if errors.Is(err, memoryops.ErrValidation) {\n        return fmt.Errorf(\"usage: bd remember <non-empty text>\")\n    }\n    return err\n}","preventionTips":["Check shell variables are non-empty before interpolating into bd remember.","Quote and verify stdin pipes feeding remember.","Fail fast in scripts when memory text is blank."],"tags":["validation","memory","empty-input"],"backgroundTag":"empty-input-validation","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}