{"record":{"id":"b6b9d59cabe285a2","repo":"gastownhall/beads","slug":"setmetadata-w","errorCode":null,"errorMessage":"SetMetadata: %w","messagePattern":"SetMetadata: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/domain/config.go","lineNumber":234,"sourceCode":"\nfunc (u *configUseCaseImpl) DeleteConfig(ctx context.Context, key string) error {\n\tif err := u.cfgRepo.DeleteConfig(ctx, key); err != nil {\n\t\treturn fmt.Errorf(\"DeleteConfig: %w\", err)\n\t}\n\treturn nil\n}\n\nfunc (u *configUseCaseImpl) GetAllConfig(ctx context.Context) (map[string]string, error) {\n\tout, err := u.cfgRepo.GetAllConfig(ctx)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"GetAllConfig: %w\", err)\n\t}\n\treturn out, nil\n}\n\nfunc (u *configUseCaseImpl) SetMetadata(ctx context.Context, key, value string) error {\n\tif err := u.cfgRepo.SetMetadata(ctx, key, value); err != nil {\n\t\treturn fmt.Errorf(\"SetMetadata: %w\", err)\n\t}\n\treturn nil\n}\n\nfunc (u *configUseCaseImpl) SetLocalMetadata(ctx context.Context, key, value string) error {\n\tif err := u.cfgRepo.SetLocalMetadata(ctx, key, value); err != nil {\n\t\treturn fmt.Errorf(\"SetLocalMetadata: %w\", err)\n\t}\n\treturn nil\n}\n\nfunc (u *configUseCaseImpl) LoadCreateContext(ctx context.Context) (CreateContext, error) {\n\tprefix, err := u.cfgRepo.GetConfig(ctx, \"issue_prefix\")\n\tif err != nil {\n\t\treturn CreateContext{}, fmt.Errorf(\"LoadCreateContext: read issue_prefix: %w\", err)\n\t}\n\tallowed, err := u.cfgRepo.GetAllowedPrefixes(ctx)\n\tif err != nil {","sourceCodeStart":216,"sourceCodeEnd":252,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/domain/config.go#L216-L252","documentation":"This is a wrapping error from ConfigUseCaseImpl.SetMetadata in internal/storage/domain/config.go:234. The use case delegated a metadata write to the config repository (cfgRepo.SetMetadata) and the repository returned an error; the use case re-wraps it with a 'SetMetadata:' prefix while preserving the original cause via %w. The real failure (DB unavailable, constraint, context cancelled) is inside the wrapped chain.","triggerScenarios":"Calling SetMetadata(ctx, key, value) on the config use case when the underlying config repository write fails — e.g. database connection error, Dolt/SQL failure, read-only store, or expired/cancelled context.","commonSituations":"DB not running or unreachable during bd commands; writing metadata in a corrupted or migrated-incompatible database; context deadline exceeded on slow storage; attempting writes on a read-only replica.","solutions":["Inspect the wrapped cause with errors.Unwrap / %v of the full chain to find the storage-level error","Verify the database is reachable and not locked (start/repair the Dolt/SQL backend)","Retry the SetMetadata call once the storage layer is healthy","Check that the key/value conform to any repository-level constraints"],"exampleFix":"// before\nif err := u.cfgRepo.SetMetadata(ctx, key, value); err != nil {\n\treturn fmt.Errorf(\"SetMetadata: %w\", err)\n}\n// after\nif err := u.cfgRepo.SetMetadata(ctx, key, value); err != nil {\n\treturn fmt.Errorf(\"SetMetadata: set key %q: %w\", key, err)\n}","handlingStrategy":"try-catch","validationCode":"// verify storage is reachable before writing metadata\nif err := pingStore(ctx); err != nil {\n\treturn fmt.Errorf(\"storage unavailable, skipping SetMetadata: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"err := uc.SetMetadata(ctx, key, value)\nif err != nil {\n\tvar wrapped error\n\tif errors.Unwrap(err) != nil {\n\t\twrapped = errors.Unwrap(err)\n\t}\n\tlog.Printf(\"SetMetadata failed for key %q: %v (cause: %v)\", key, err, wrapped)\n\treturn err\n}","preventionTips":["Health-check the storage backend before write operations","Always inspect the wrapped cause with errors.Unwrap or errors.Is/As","Keep contexts short-lived with explicit deadlines","Avoid writing metadata concurrently from multiple processes"],"tags":["storage","metadata","error-wrapping"],"backgroundTag":"metadata-write-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}