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