@@ -460,24 +460,43 @@ func (c AuthConnectionCmd) Submit(ctx context.Context, in AuthConnectionSubmitIn
460460 return util.CleanedUpSdkError {Err : fmt .Errorf ("failed to fetch connection for MFA option resolution: %w" , err )}
461461 }
462462 if len (conn .MfaOptions ) > 0 {
463- resolved := false
463+ resolvedType := ""
464+ inputOption := in .MfaOptionID
465+
466+ // Match by type first across all options, then label, then display string.
467+ // This ensures an exact type match is never shadowed by an earlier label match.
464468 for _ , opt := range conn .MfaOptions {
465- displayName := fmt .Sprintf ("%s (%s)" , opt .Label , opt .Type )
466- if strings .EqualFold (in .MfaOptionID , opt .Type ) ||
467- strings .EqualFold (in .MfaOptionID , opt .Label ) ||
468- strings .EqualFold (in .MfaOptionID , displayName ) {
469- in .MfaOptionID = opt .Type
470- resolved = true
469+ if strings .EqualFold (inputOption , opt .Type ) {
470+ resolvedType = opt .Type
471471 break
472472 }
473473 }
474- if ! resolved {
474+ if resolvedType == "" {
475+ for _ , opt := range conn .MfaOptions {
476+ if strings .EqualFold (inputOption , opt .Label ) {
477+ resolvedType = opt .Type
478+ break
479+ }
480+ }
481+ }
482+ if resolvedType == "" {
483+ for _ , opt := range conn .MfaOptions {
484+ displayName := fmt .Sprintf ("%s (%s)" , opt .Label , opt .Type )
485+ if strings .EqualFold (inputOption , displayName ) {
486+ resolvedType = opt .Type
487+ break
488+ }
489+ }
490+ }
491+ if resolvedType == "" {
475492 available := make ([]string , 0 , len (conn .MfaOptions ))
476493 for _ , opt := range conn .MfaOptions {
477494 available = append (available , fmt .Sprintf ("%s (%s)" , opt .Label , opt .Type ))
478495 }
479496 return fmt .Errorf ("unknown MFA option %q; available: %s" , in .MfaOptionID , strings .Join (available , ", " ))
480497 }
498+
499+ in .MfaOptionID = resolvedType
481500 }
482501 }
483502
0 commit comments