diff --git a/internal/utils/id_parser.go b/internal/utils/id_parser.go index 00b1396e..8d31033a 100644 --- a/internal/utils/id_parser.go +++ b/internal/utils/id_parser.go @@ -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