{"record":{"id":"d169c729f3b8159c","repo":"gastownhall/beads","slug":"failed-to-get-comments-w","errorCode":null,"errorMessage":"failed to get comments: %w","messagePattern":"failed to get comments: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/dolt/events.go","lineNumber":135,"sourceCode":"\treturn result, nil\n}\n\n// GetIssueComments retrieves all comments for an issue\nfunc (s *DoltStore) GetIssueComments(ctx context.Context, issueID string) ([]*types.Comment, error) {\n\ttable := \"comments\"\n\tif s.isActiveWisp(ctx, issueID) {\n\t\ttable = \"wisp_comments\"\n\t}\n\n\t//nolint:gosec // G201: table is hardcoded\n\trows, err := s.queryContext(ctx, fmt.Sprintf(`\n\t\tSELECT id, issue_id, author, text, created_at\n\t\tFROM %s\n\t\tWHERE issue_id = ?\n\t\tORDER BY created_at ASC, id ASC\n\t`, table), issueID)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get comments: %w\", err)\n\t}\n\tdefer rows.Close()\n\n\treturn scanComments(rows)\n}\n\n// GetIssueCommentsPage returns one keyset page of an issue's comments in\n// (created_at ASC, id ASC) order, resuming strictly after the cursor. See the\n// storage.Storage doc for the ordering, sargability, and page-walk-equals-full-\n// read contract.\nfunc (s *DoltStore) GetIssueCommentsPage(ctx context.Context, issueID string, after storage.CommentPageCursor, limit int) ([]*types.Comment, error) {\n\tvar result []*types.Comment\n\terr := s.withReadTx(ctx, func(tx *sql.Tx) error {\n\t\tvar err error\n\t\tresult, err = issueops.GetIssueCommentsPageInTx(ctx, tx, issueID, after, limit)\n\t\treturn err\n\t})\n\treturn result, err","sourceCodeStart":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/dolt/events.go#L117-L153","documentation":"GetIssueComments fails when the SELECT of comments for an issue cannot be executed. The error from the query layer (bad table, connection loss, canceled context) is wrapped as 'failed to get comments'. Reached via IterIssueComments when iterating issue comments.","triggerScenarios":"Querying comments when the comments table is missing (uninitialized/partially migrated DB), the issue_id filter references a malformed ID, the Dolt connection dropped mid-query, or the context was canceled during IterIssueComments.","commonSituations":"`bd show <issue>` or comment listing after a schema migration changed the comments table; reading from a database created by a newer bd version; Dolt server restart between opening the store and issuing the query.","solutions":["Confirm the comments table exists with the expected columns (`dolt sql -q \"DESCRIBE comments\"` or equivalent).","Run `bd doctor` to detect schema/version drift and apply migrations.","Restart the bd process / Dolt server if the error indicates a broken connection.","Check that the issue ID passed to GetIssueComments is a valid, correctly formatted ID."],"exampleFix":"// before: swallowing the distinction between empty and failed\ncomments, err := store.GetIssueComments(ctx, id)\nif err != nil {\n\tcomments = nil\n}\n// after: surface the error to the user\ncomments, err := store.GetIssueComments(ctx, id)\nif err != nil {\n\treturn fmt.Errorf(\"cannot list comments for %s: %w\", id, err)\n}","handlingStrategy":"type-guard","validationCode":"// Go: confirm the comments table exists before listing\n_, err := db.Query(\"SELECT 1 FROM comments LIMIT 1\")\nif err != nil {\n\treturn fmt.Errorf(\"comments table missing (run migrations): %w\", err)\n}","typeGuard":"func IsCommentsFetchError(err error) bool {\n\treturn err != nil && strings.Contains(err.Error(), \"failed to get comments\")\n}","tryCatchPattern":"comments, err := store.GetIssueComments(ctx, issueID)\nif err != nil {\n\treturn fmt.Errorf(\"cannot read comments for %s: %w\", issueID, err)\n}","preventionTips":["Run migrations/doctor after any bd upgrade before reading comments.","Use well-formed issue IDs; validate input before querying.","Keep Dolt server sessions alive; avoid long-lived processes across server restarts.","Check connectivity if listing comments suddenly fails repo-wide."],"tags":["database","dolt","query","comments"],"backgroundTag":"sql-query-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}