Merge pull request #337 from cpdata/fix-resolve-partial-id

Fix: Restore JSON unmarshaling in ResolveID for fixing failed bd show/update/close operations
This commit is contained in:
Steve Yegge
2025-11-20 09:15:08 -08:00
committed by GitHub
2 changed files with 27 additions and 4 deletions

View File

@@ -34,7 +34,12 @@ var showCmd = &cobra.Command{
fmt.Fprintf(os.Stderr, "Error resolving ID %s: %v\n", id, err)
os.Exit(1)
}
resolvedIDs = append(resolvedIDs, string(resp.Data))
var resolvedID string
if err := json.Unmarshal(resp.Data, &resolvedID); err != nil {
fmt.Fprintf(os.Stderr, "Error unmarshaling resolved ID: %v\n", err)
os.Exit(1)
}
resolvedIDs = append(resolvedIDs, resolvedID)
}
} else {
// In direct mode, resolve via storage
@@ -392,7 +397,12 @@ var updateCmd = &cobra.Command{
fmt.Fprintf(os.Stderr, "Error resolving ID %s: %v\n", id, err)
os.Exit(1)
}
resolvedIDs = append(resolvedIDs, string(resp.Data))
var resolvedID string
if err := json.Unmarshal(resp.Data, &resolvedID); err != nil {
fmt.Fprintf(os.Stderr, "Error unmarshaling resolved ID: %v\n", err)
os.Exit(1)
}
resolvedIDs = append(resolvedIDs, resolvedID)
}
} else {
var err error
@@ -710,7 +720,12 @@ var closeCmd = &cobra.Command{
fmt.Fprintf(os.Stderr, "Error resolving ID %s: %v\n", id, err)
os.Exit(1)
}
resolvedIDs = append(resolvedIDs, string(resp.Data))
var resolvedID string
if err := json.Unmarshal(resp.Data, &resolvedID); err != nil {
fmt.Fprintf(os.Stderr, "Error unmarshaling resolved ID: %v\n", err)
os.Exit(1)
}
resolvedIDs = append(resolvedIDs, resolvedID)
}
} else {
var err error

View File

@@ -37,6 +37,14 @@ 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
}
// Get the configured prefix
prefix, err := store.GetConfig(ctx, "issue_prefix")
if err != nil || prefix == "" {
@@ -63,7 +71,7 @@ func ResolvePartialID(ctx context.Context, store storage.Storage, input string)
normalizedID = prefixWithHyphen + input
}
// First try exact match
// First try exact match on normalized ID
issue, err := store.GetIssue(ctx, normalizedID)
if err == nil && issue != nil {
return normalizedID, nil