Skip to content

Commit bfc0993

Browse files
committed
1 parent cd74174 commit bfc0993

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

internal/ankacloud/controller.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,9 @@ func (c *controller) GetInstanceByExternalId(ctx context.Context, externalId str
230230
}
231231
}
232232

233-
// As a last resort, return the first matching instance (could be Error/Terminated)
234-
return matchingInstances[0], nil
233+
// No instances in a usable state - fail explicitly instead of returning Error/Terminated instances
234+
return nil, fmt.Errorf("instance with external id %s exists but is not in a usable state (found state: %s)",
235+
externalId, matchingInstances[0].State)
235236
}
236237

237238
func (c *controller) GetTemplateIdByName(ctx context.Context, templateName string) (string, error) {

0 commit comments

Comments
 (0)