gastownhall/beads · error
SetLocalMetadata: %w
Error message
SetLocalMetadata: %w
What it means
Wrapping error from ConfigUseCaseImpl.SetLocalMetadata in internal/storage/domain/config.go:241. Identical pattern to SetMetadata but targets the local-scope metadata repository method (SetLocalMetadata), which writes metadata that stays on the local machine rather than syncing. The repository error is preserved with %w under a 'SetLocalMetadata:' prefix.
Source
Thrown at internal/storage/domain/config.go:241
func (u *configUseCaseImpl) GetAllConfig(ctx context.Context) (map[string]string, error) {
out, err := u.cfgRepo.GetAllConfig(ctx)
if err != nil {
return nil, fmt.Errorf("GetAllConfig: %w", err)
}
return out, nil
}
func (u *configUseCaseImpl) SetMetadata(ctx context.Context, key, value string) error {
if err := u.cfgRepo.SetMetadata(ctx, key, value); err != nil {
return fmt.Errorf("SetMetadata: %w", err)
}
return nil
}
func (u *configUseCaseImpl) SetLocalMetadata(ctx context.Context, key, value string) error {
if err := u.cfgRepo.SetLocalMetadata(ctx, key, value); err != nil {
return fmt.Errorf("SetLocalMetadata: %w", err)
}
return nil
}
func (u *configUseCaseImpl) LoadCreateContext(ctx context.Context) (CreateContext, error) {
prefix, err := u.cfgRepo.GetConfig(ctx, "issue_prefix")
if err != nil {
return CreateContext{}, fmt.Errorf("LoadCreateContext: read issue_prefix: %w", err)
}
allowed, err := u.cfgRepo.GetAllowedPrefixes(ctx)
if err != nil {
return CreateContext{}, fmt.Errorf("LoadCreateContext: read allowed_prefixes: %w", err)
}
customTypes, err := u.cfgRepo.GetCustomTypes(ctx)
if err != nil {
return CreateContext{}, fmt.Errorf("LoadCreateContext: read custom types: %w", err)
}
customStatuses, err := u.cfgRepo.GetCustomStatuses(ctx)View on GitHub (pinned to 71377f2769)
Solutions
- Unwrap the error chain to identify the storage-level cause
- Verify the local database file exists and is writable (check directory permissions)
- Re-initialize or repair the local store if the file is missing/corrupt
- Retry the write after resolving the local storage issue
Example fix
// before
if err := u.cfgRepo.SetLocalMetadata(ctx, key, value); err != nil {
return fmt.Errorf("SetLocalMetadata: %w", err)
}
// after
if err := u.cfgRepo.SetLocalMetadata(ctx, key, value); err != nil {
return fmt.Errorf("SetLocalMetadata: set local key %q: %w", key, err)
} Defensive patterns
Strategy: try-catch
Validate before calling
// ensure the local store exists and is writable
if _, err := os.Stat(localDBPath); err != nil {
return fmt.Errorf("local store missing, run bd init first: %w", err)
}
if err := checkWritable(localDBPath); err != nil {
return fmt.Errorf("local store not writable: %w", err)
} Try / catch
err := uc.SetLocalMetadata(ctx, key, value)
if err != nil {
if isPermissionErr(errors.Unwrap(err)) {
fixLocalPermissions(localDBPath)
}
return fmt.Errorf("local metadata write failed: %w", err)
} Prevention
- Initialize the local store (bd init) before metadata writes
- Check directory permissions on the local data path
- Don't hold the local DB open in another process during writes
- Unwrap the error to distinguish local-I/O issues from SQL issues
When it happens
Trigger: Calling SetLocalMetadata(ctx, key, value) when the config repository's local metadata write fails — storage I/O error, missing local DB file, permission problem, or cancelled context.
Common situations: Local .beads database file missing, corrupted, or locked by another process; permission denied on the local data directory; running bd from a directory without an initialized local store.
Related errors
- SetMetadata: %w
- not found
- load wisp labels: %w
- edge %d %s->%s: checking planned blocking cycle: %w
- reading existing dependencies for %s: %w
AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30).
Data as JSON: /api/errors/6669196ee4a03273.
Report an issue: GitHub.