Parcourir la source

fix: replace break with continue when handling streaming response

Yeuoly il y a 7 mois
Parent
commit
a1bbaf109b
1 fichiers modifiés avec 6 ajouts et 7 suppressions
  1. 6 7
      internal/core/dify_invocation/real/http_request.go

+ 6 - 7
internal/core/dify_invocation/real/http_request.go

@@ -90,13 +90,12 @@ func StreamResponse[T any](i *RealBackwardsInvocation, method string, path strin
 				break
 			}
 
-			// check if t.Data is a map[string]any
-			if reflect.TypeOf(*t.Data).Kind() == reflect.Map {
-				newResponse.Write(*t.Data)
-				break
-			} else if err := validators.GlobalEntitiesValidator.Struct(t.Data); err != nil {
-				newResponse.WriteError(fmt.Errorf("validate request failed: %s", err.Error()))
-				break
+			// check if t.Data is a map[string]any, skip validation if it is
+			if reflect.TypeOf(*t.Data).Kind() != reflect.Map {
+				if err := validators.GlobalEntitiesValidator.Struct(t.Data); err != nil {
+					newResponse.WriteError(fmt.Errorf("validate request failed: %s", err.Error()))
+					break
+				}
 			}
 
 			newResponse.Write(*t.Data)