fix: use SearchIssues for ID resolution (GH#942)

Use SearchIssues with filter.IDs instead of GetIssue in ResolvePartialID.
This fixes inconsistencies where bd list could find issues that bd show
could not, due to subtle query differences between the two code paths.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
wolf
2026-01-10 00:37:29 -08:00
committed by Steve Yegge
parent b4118e9f60
commit 7c83187bdd

View File

@@ -37,12 +37,13 @@ func ParseIssueID(input string, prefix string) string {
// - No issue found matching the ID
// - Multiple issues match (ambiguous prefix)
func ResolvePartialID(ctx context.Context, store storage.Storage, input string) (string, error) {
// Fast path: if the user typed an exact ID that exists, return it as-is.
// This preserves behavior where issue IDs may not match the configured
// issue_prefix (e.g. cross-repo IDs like "ao-izl"), while still allowing
// prefix-based and hash-based resolution for other inputs.
if issue, err := store.GetIssue(ctx, input); err == nil && issue != nil {
return input, nil
// Fast path: Use SearchIssues with exact ID filter (GH#942).
// This uses the same query path as "bd list --id", ensuring consistency.
// Previously we used GetIssue which could fail in cases where SearchIssues
// with filter.IDs succeeded, likely due to subtle query differences.
exactFilter := types.IssueFilter{IDs: []string{input}}
if issues, err := store.SearchIssues(ctx, "", exactFilter); err == nil && len(issues) > 0 {
return issues[0].ID, nil
}
// Get the configured prefix
@@ -71,10 +72,10 @@ func ResolvePartialID(ctx context.Context, store storage.Storage, input string)
normalizedID = prefixWithHyphen + input
}
// First try exact match on normalized ID
issue, err := store.GetIssue(ctx, normalizedID)
if err == nil && issue != nil {
return normalizedID, nil
// Try exact match on normalized ID using SearchIssues (GH#942)
normalizedFilter := types.IssueFilter{IDs: []string{normalizedID}}
if issues, err := store.SearchIssues(ctx, "", normalizedFilter); err == nil && len(issues) > 0 {
return issues[0].ID, nil
}
// If exact match failed, try substring search