{"record":{"id":"7a2b55584e260785","repo":"gastownhall/beads","slug":"getting-issue-s-w","errorCode":null,"errorMessage":"getting issue %s: %w","messagePattern":"getting issue (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/dolt/slots.go","lineNumber":93,"sourceCode":"//\n// Built on MergeMetadata so the read-modify-write is atomic: two concurrent\n// SlotSet calls on different keys both survive. The string value is stored as a\n// JSON string (json.Marshal(value) yields \"value\"), keeping the stored metadata\n// byte-compatible with the historical whole-metadata rewrite.\nfunc (s *DoltStore) SlotSet(ctx context.Context, issueID, key, value, actor string) error {\n\traw, err := json.Marshal(value)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"marshaling slot value for %s.%s: %w\", issueID, key, err)\n\t}\n\treturn s.MergeMetadata(ctx, issueID, key, raw, actor)\n}\n\n// SlotGet retrieves the value of a metadata key from an issue.\n// Returns an error if the issue has no metadata or the key is not found.\nfunc (s *DoltStore) SlotGet(ctx context.Context, issueID, key string) (string, error) {\n\tissue, err := s.GetIssue(ctx, issueID)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"getting issue %s: %w\", issueID, err)\n\t}\n\n\tif len(issue.Metadata) == 0 {\n\t\treturn \"\", fmt.Errorf(\"no slot %q on %s: no metadata\", key, issueID)\n\t}\n\n\tmetadata := make(map[string]interface{})\n\tif err := json.Unmarshal(issue.Metadata, &metadata); err != nil {\n\t\treturn \"\", fmt.Errorf(\"parsing metadata for %s: %w\", issueID, err)\n\t}\n\n\tval, ok := metadata[key]\n\tif !ok {\n\t\treturn \"\", fmt.Errorf(\"no slot %q on %s: key not found\", key, issueID)\n\t}\n\n\tswitch v := val.(type) {\n\tcase string:","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/dolt/slots.go#L75-L111","documentation":"SlotGet failed while fetching the underlying issue before reading its metadata slot. The original error from GetIssue (issue not found, DB connection failure, query error, etc.) is wrapped with the issue ID so the caller knows which record failed. This is a wrapper error: the root cause is the embedded %w error.","triggerScenarios":"Calling DoltStore.SlotGet(ctx, issueID, key) when GetIssue fails — most commonly the issue ID does not exist, the database is unreachable, or the underlying SQL query fails.","commonSituations":"Typo'd or stale issue ID passed to SlotGet; issue was deleted between ID capture and the slot read; embedded Dolt server not running; wrong --db path so the issues table is empty.","solutions":["Verify the issue ID exists (e.g. bd show <id> or query the issues table) before calling SlotGet.","Inspect the wrapped cause via errors.Unwrap / errors.Is to distinguish 'not found' from connection failures.","Confirm the Dolt database is reachable and the correct branch is checked out (bd doctor)."],"exampleFix":"// before\nval, err := store.SlotGet(ctx, id, key)\nif err != nil {\n\treturn err // ambiguous root cause\n}\n// after\nval, err := store.SlotGet(ctx, id, key)\nif err != nil {\n\tif errors.Is(err, storage.ErrNotFound) {\n\t\treturn fmt.Errorf(\"issue %s not found\", id)\n\t}\n\treturn err\n}","handlingStrategy":"try-catch","validationCode":"if _, err := store.GetIssue(ctx, issueID); err != nil {\n\t// issue missing or DB down; skip SlotGet\n\treturn err\n}","typeGuard":"func isNotFound(err error) bool {\n\treturn errors.Is(err, storage.ErrNotFound)\n}","tryCatchPattern":"val, err := store.SlotGet(ctx, id, key)\nif err != nil {\n\tvar inner error\n\tif errors.As(err, &inner) && errors.Is(inner, storage.ErrNotFound) {\n\t\t// handle missing issue\n\t}\n\treturn err\n}","preventionTips":["Resolve issue IDs from the store itself rather than accepting free-form strings.","Check errors.Is on the unwrapped cause instead of string matching.","Ensure the Dolt DB is healthy (bd doctor) before batch slot reads."],"tags":["database","error-wrapping","dolt","metadata"],"backgroundTag":"issue-not-found","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}