gastownhall/beads · warning · memoryops.ErrValidation

memory content cannot be empty

Error message

memory content cannot be empty

What it means

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.

Source

Thrown at internal/memoryapi/memoryapi.go:82

	slug := strings.Join(parts, "-")

	if len(slug) > 60 {
		slug = slug[:60]
		// A cap that landed mid-word must not leave the key ending in the
		// separator.
		slug = strings.TrimRight(slug, "-")
	}
	return slug
}

// ValidateContent checks the content a caller wants to remember.
//
// The prose is `bd remember`'s, preserved: it is the sentence agents have been
// reading since the command shipped, and the sentinel is what code classifies
// on.
func ValidateContent(content string) error {
	if strings.TrimSpace(content) == "" {
		return fmt.Errorf("%w: memory content cannot be empty", memoryops.ErrValidation)
	}
	return nil
}

// ValidateKey checks a key a caller wants to read or remove, and returns it
// UNCHANGED.
//
// Unchanged is the whole point: `bd remember --key` accepts any string, so a
// key differing from another only by surrounding space is a key someone may
// genuinely hold, and trimming it here would answer a different question from
// the one asked. The only rule is that a key has to name something.
func ValidateKey(key string) (string, error) {
	if strings.TrimSpace(key) == "" {
		return "", fmt.Errorf("%w: memory key must not be empty", memoryops.ErrValidation)
	}
	return key, nil
}

View on GitHub (pinned to 71377f2769)

Solutions

  1. Pass non-empty text to bd remember / ValidateContent.
  2. Check the shell variable or stdin source actually contains the intended content.
  3. Handle the error by prompting for or defaulting the memory text before storing.

Example fix

// before
if err := memoryapi.ValidateContent(note); err != nil { ... } // note == ""
// after
if strings.TrimSpace(note) == "" {
    return fmt.Errorf("nothing to remember: provide content")
}
if err := memoryapi.ValidateContent(note); err != nil { ... }
Defensive patterns

Strategy: validation

Validate before calling

if strings.TrimSpace(content) == "" {
    return fmt.Errorf("nothing to remember: content is empty")
}

Type guard

func hasMemoryContent(s string) bool { return strings.TrimSpace(s) != "" }

Try / catch

if err := memoryapi.ValidateContent(content); err != nil {
    if errors.Is(err, memoryops.ErrValidation) {
        return fmt.Errorf("usage: bd remember <non-empty text>")
    }
    return err
}

Prevention

When it happens

Trigger: Calling ValidateContent("") or with a whitespace-only string; calling bd remember with an empty message; ResolveKey receiving content that fails this check.

Common situations: 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.

Related errors


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