extractFallbackReason extracts the reason for fallback from ValidationResult Prefers structured ReasonCode field, falls back to message parsing for backward compatibility
(result *vsa.ValidationResult)
| 723 | // extractFallbackReason extracts the reason for fallback from ValidationResult |
| 724 | // Prefers structured ReasonCode field, falls back to message parsing for backward compatibility |
| 725 | func extractFallbackReason(result *vsa.ValidationResult) string { |
| 726 | if result == nil { |
| 727 | return unknownReason |
| 728 | } |
| 729 | |
| 730 | // Prefer structured ReasonCode field if available |
| 731 | if result.ReasonCode != "" { |
| 732 | if display, ok := reasonCodeToDisplay[result.ReasonCode]; ok { |
| 733 | return display |
| 734 | } |
| 735 | // Unknown reason code, fall through to message parsing |
| 736 | } |
| 737 | |
| 738 | // Fallback to message parsing for backward compatibility (e.g., old ValidationResult without ReasonCode) |
| 739 | return extractReasonFromMessage(result.Message) |
| 740 | } |
| 741 | |
| 742 | // extractReasonFromMessage parses reason from message text (fallback for old ValidationResult) |
| 743 | func extractReasonFromMessage(message string) string { |