Ver Fonte

fix: JSON string marshalling in webhook uses raw strings

jamesread há 5 meses atrás
pai
commit
3d106ee13b
1 ficheiros alterados com 6 adições e 1 exclusões
  1. 6 1
      service/internal/webhooks/jsonpath.go

+ 6 - 1
service/internal/webhooks/jsonpath.go

@@ -25,7 +25,12 @@ func (m *JSONMatcher) MatchPath(pathExpr string, expectedValue string) (bool, er
 		return false, err
 		return false, err
 	}
 	}
 
 
-	// Marshal to JSON for consistent string representation
+	// For string values, compare directly without marshaling
+	if strValue, ok := value.(string); ok {
+		return strValue == expectedValue, nil
+	}
+
+	// For non-string values, marshal to JSON for consistent string representation
 	jsonBytes, err := json.Marshal(value)
 	jsonBytes, err := json.Marshal(value)
 	if err != nil {
 	if err != nil {
 		return false, fmt.Errorf("failed to marshal extracted value: %w", err)
 		return false, fmt.Errorf("failed to marshal extracted value: %w", err)