fix(mol): prevent nil pointer dereference in wisp create
GetIssue returns (nil, nil) when an issue is not found, but the code assumed a non-nil issue when err was nil. Added nil checks before accessing issue fields. Fixes crash when running `bd mol wisp create` with nonexistent proto. Closes: gt-2uzn2 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
committed by
Steve Yegge
parent
7fe824781a
commit
6dfd7588b3
@@ -211,11 +211,16 @@ func runWispCreate(cmd *cobra.Command, args []string) {
|
||||
}
|
||||
|
||||
// Load the proto
|
||||
// Note: GetIssue returns (nil, nil) for not-found, so check both
|
||||
protoIssue, err := store.GetIssue(ctx, protoID)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error loading proto %s: %v\n", protoID, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
if protoIssue == nil {
|
||||
fmt.Fprintf(os.Stderr, "Error: proto not found: %s\n", protoID)
|
||||
os.Exit(1)
|
||||
}
|
||||
if !isProtoIssue(protoIssue) {
|
||||
fmt.Fprintf(os.Stderr, "Error: %s is not a proto (missing '%s' label)\n", protoID, MoleculeLabel)
|
||||
os.Exit(1)
|
||||
@@ -297,7 +302,8 @@ func isProtoIssue(issue *types.Issue) bool {
|
||||
// resolvePartialIDDirect resolves a partial ID directly from store
|
||||
func resolvePartialIDDirect(ctx context.Context, partial string) (string, error) {
|
||||
// Try direct lookup first
|
||||
if issue, err := store.GetIssue(ctx, partial); err == nil {
|
||||
// Note: GetIssue returns (nil, nil) for not-found, so check both
|
||||
if issue, err := store.GetIssue(ctx, partial); err == nil && issue != nil {
|
||||
return issue.ID, nil
|
||||
}
|
||||
// Search by prefix
|
||||
|
||||
Reference in New Issue
Block a user