{"record":{"id":"299cf0e499aaef67","repo":"gastownhall/beads","slug":"failed-to-find-candidate-issues-w","errorCode":null,"errorMessage":"failed to find candidate issues: %w","messagePattern":"failed to find candidate issues: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/migrate_issues.go","lineNumber":142,"sourceCode":"\tOrphans           int      `json:\"orphans\"`\n\tOrphanSamples     []string `json:\"orphan_samples,omitempty\"`\n\tIssueIDs          []string `json:\"issue_ids\"`\n\tFrom              string   `json:\"from\"`\n\tTo                string   `json:\"to\"`\n}\n\nfunc executeMigrateIssues(ctx context.Context, p migrateIssuesParams) error {\n\ts := store // use global Storage interface\n\n\t// Step 1: Validate repositories exist\n\tif err := validateRepos(ctx, s, p.from, p.to, p.strict); err != nil {\n\t\treturn err\n\t}\n\n\t// Step 2: Build initial candidate set C using filters\n\tcandidates, err := findCandidateIssues(ctx, s, p)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to find candidate issues: %w\", err)\n\t}\n\n\tif len(candidates) == 0 {\n\t\tif jsonOutput {\n\t\t\treturn outputJSON(map[string]interface{}{\n\t\t\t\t\"message\": \"No issues match the specified filters\",\n\t\t\t})\n\t\t}\n\t\tfmt.Println(\"Nothing to do: no issues match the specified filters\")\n\t\treturn nil\n\t}\n\n\t// Step 3: Expand set to M (migration set) based on --include\n\tmigrationSet, dependencyStats, err := expandMigrationSet(ctx, s, candidates, p)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to compute migration set: %w\", err)\n\t}\n","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/migrate_issues.go#L124-L160","documentation":"This error wraps any failure from findCandidateIssues during step 2 of `bd migrate-issues`, which builds the initial candidate set C of issues matching the user's filters. It indicates the store query for issues matching the --from-repo/filter parameters failed before migration planning could proceed. The wrapped inner error carries the actual cause (storage, query, or context failure).","triggerScenarios":"findCandidateIssues(ctx, s, p) returns a non-nil error while building the candidate set from the applied filters (repo, label, status, priority filters in the migrate params).","commonSituations":"Corrupt or locked Dolt database during migration; invalid filter combinations that the store query rejects; context cancellation because the user Ctrl-C'd a long-running migration; schema mismatch after a beads version upgrade.","solutions":["Read the wrapped inner error (%w) to identify the actual store failure","Verify the database is healthy with `bd doctor` and that no other bd process holds a lock","Re-run with simpler filters to isolate which filter causes the query to fail","Check that the beads version matches the database schema (run any pending migrations)"],"exampleFix":"// before: bare call hides which filter failed\ncandidates, err := findCandidateIssues(ctx, s, p)\n// after: log filters with the error for diagnosis\nif err != nil {\n    return fmt.Errorf(\"failed to find candidate issues (repo=%q filters=%v): %w\", p.from, p.filters, err)\n}","handlingStrategy":"try-catch","validationCode":"// before running migrate, confirm the source has matching issues\nbd list --repo old-repo --limit 1\nbd doctor","typeGuard":null,"tryCatchPattern":"if err := runMigrate(); err != nil {\n    var inner error\n    if errors.As(err, &inner) || errors.Unwrap(err) != nil {\n        log.Printf(\"candidate lookup failed: %v\", errors.Unwrap(err))\n    }\n    return err\n}","preventionTips":["Always validate filters with bd list before migrating","Keep the database schema current with your bd binary","Avoid running migrations concurrently with bd sync","Test migrations on a database copy first"],"tags":["cli","migrations","storage"],"backgroundTag":"migrate-candidate-query-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}