anon-iclr-submission/benchname-bug-localization huggingface dataset:
Repository: telstra/open-kilda
Issue: Create LAG without `lacp_reply` in request causes 500 response

**Steps to reproduce:**
1. send request `POST /api/v2/switches/{switch_id}/lags` with body `{ "port_numbers": [12, 14]}` (without `lacp_reply`)

**Expected result:**
1. lacp_reply will be set to true by default 
2. LAG will be created

**Actual result:**
500 Internal server error

Changed files:
src-java/northbound-service/northbound-api/src/main/java/org/openkilda/northbound/dto/v2/switches/LagPortRequest.java

diff --git a/src-java/northbound-service/northbound-api/src/main/java/org/openkilda/northbound/dto/v2/switches/LagPortRequest.java b/src-java/northbound-service/northbound-api/src/main/java/org/openkilda/northbound/dto/v2/switches/LagPortRequest.java
index 8d4362bd6..0c278e745 100644
--- a/src-java/northbound-service/northbound-api/src/main/java/org/openkilda/northbound/dto/v2/switches/LagPortRequest.java
+++ b/src-java/northbound-service/northbound-api/src/main/java/org/openkilda/northbound/dto/v2/switches/LagPortRequest.java
@@ -15,11 +15,9 @@
 
 package org.openkilda.northbound.dto.v2.switches;
 
-import com.fasterxml.jackson.databind.PropertyNamingStrategy;
-import com.fasterxml.jackson.databind.annotation.JsonNaming;
-import lombok.AllArgsConstructor;
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
 import lombok.Builder;
-import lombok.Builder.Default;
 import lombok.Data;
 import lombok.NoArgsConstructor;
 
@@ -27,11 +25,23 @@ import java.util.Set;
 
 @Data
 @NoArgsConstructor
-@AllArgsConstructor
-@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class)
-@Builder
 public class LagPortRequest {
+    @JsonProperty("port_numbers")
     private Set<Integer> portNumbers;
-    @Default
-    private Boolean lacpReply = true;
+
+    @JsonProperty("lacp_reply")
+    private Boolean lacpReply;
+
+    @Builder
+    @JsonCreator
+    public LagPortRequest(
+            @JsonProperty("port_numbers") Set<Integer> portNumbers,
+            @JsonProperty("lacp_reply") Boolean lacpReply) {
+        this.portNumbers = portNumbers;
+        setLacpReply(lacpReply);
+    }
+
+    public void setLacpReply(Boolean lacpReply) {
+        this.lacpReply = lacpReply == null ? true : lacpReply;
+    }
 }
Repository: telstra/open-kilda
Issue: Can't update Y flow if one sub flow is one switch and other one is multi switch

**Steps to repoduse:**
1. Create Y flow where A-end == Z-end and B-end != Z-end
Example: 
```
{
  "y_flow_id": "flow1",
  "shared_endpoint": {
    "port_number": 10,
    "switch_id": "2"
  },
  "maximum_bandwidth": 10000,
  "ignore_bandwidth": true,
  "sub_flows": [
    {
      "flow_id": "sub1",
      "endpoint": {
        "inner_vlan_id": 0,
        "port_number": 10,
        "switch_id": "9",
        "vlan_id": 123
      },
      "shared_endpoint": {
        "inner_vlan_id": 0,
        "vlan_id": 456
      }
    },
{
      "flow_id": "sub2",
      "endpoint": {
        "inner_vlan_id": 0,
        "port_number": 10,
        "switch_id": "2",
        "vlan_id": 345
      },
      "shared_endpoint": {
        "inner_vlan_id": 0,
        "vlan_id": 789
      }
    }
  ]
}
```

2. Update the flow by PATCH
```
{
  "maximum_bandwidth": 20000
}
```

**Expected result:**
Flow was updated

**Actual result:**
Time out


Changed files:
src-java/flowhs-topology/flowhs-storm-topology/src/main/java/org/openkilda/wfm/topology/flowhs/fsm/yflow/update/actions/ValidateYFlowAction.java

diff --git a/src-java/flowhs-topology/flowhs-storm-topology/src/main/java/org/openkilda/wfm/topology/flowhs/fsm/yflow/update/actions/ValidateYFlowAction.java b/src-java/flowhs-topology/flowhs-storm-topology/src/main/java/org/openkilda/wfm/topology/flowhs/fsm/yflow/update/actions/ValidateYFlowAction.java
index 71ae77073..6787f6c07 100644
--- a/src-java/flowhs-topology/flowhs-storm-topology/src/main/java/org/openkilda/wfm/topology/flowhs/fsm/yflow/update/actions/ValidateYFlowAction.java
+++ b/src-java/flowhs-topology/flowhs-storm-topology/src/main/java/org/openkilda/wfm/topology/flowhs/fsm/yflow/update/actions/ValidateYFlowAction.java
@@ -145,12 +145,20 @@ public class ValidateYFlowAction extends
 
     private String getMainAffinityFlowId(YFlow yFlow) {
         // TODO: maybe we should add filtering of one switch sub flows into method getSubFlows()
-        YSubFlow multiSwitchFlows = yFlow.getSubFlows().stream()
+        YSubFlow flowInAffinityGroup = yFlow.getSubFlows().stream()
+                .filter(sub -> sub.getFlow().getAffinityGroupId() != null)
+                .findAny()
+                .orElse(null);
+        if (flowInAffinityGroup != null) {
+            return flowInAffinityGroup.getFlow().getAffinityGroupId();
+        }
+
+        YSubFlow multiSwitchFlow = yFlow.getSubFlows().stream()
                 .filter(sub -> !sub.isOneSwitchYFlow(yFlow.getSharedEndpoint().getSwitchId()))
                 .findAny()
                 .orElse(null);
-        if (multiSwitchFlows != null) {
-            return multiSwitchFlows.getFlow().getAffinityGroupId();
+        if (multiSwitchFlow != null) {
+            return multiSwitchFlow.getSubFlowId();
         } else {
             // if there is no multi switch flows we have to use one switch flow
             YSubFlow oneSwitchSubFlow = yFlow.getSubFlows().stream()
Repository: telstra/open-kilda
Issue: duplicated update event for in ha-flow history

steps to reproduce

1. create ha flow
2. update ha flow
3. get ha flow history

Actual result: ha flow history contains 2 update entries with the same data 
Expected result: 1 update event in history 


Changed files:
src-java/flowhs-topology/flowhs-storm-topology/src/main/java/org/openkilda/wfm/topology/flowhs/fsm/haflow/update/actions/UpdateHaFlowAction.java

diff --git a/src-java/flowhs-topology/flowhs-storm-topology/src/main/java/org/openkilda/wfm/topology/flowhs/fsm/haflow/update/actions/UpdateHaFlowAction.java b/src-java/flowhs-topology/flowhs-storm-topology/src/main/java/org/openkilda/wfm/topology/flowhs/fsm/haflow/update/actions/UpdateHaFlowAction.java
index a34cf6a9f..b393e1bcf 100644
--- a/src-java/flowhs-topology/flowhs-storm-topology/src/main/java/org/openkilda/wfm/topology/flowhs/fsm/haflow/update/actions/UpdateHaFlowAction.java
+++ b/src-java/flowhs-topology/flowhs-storm-topology/src/main/java/org/openkilda/wfm/topology/flowhs/fsm/haflow/update/actions/UpdateHaFlowAction.java
@@ -26,7 +26,6 @@ import org.openkilda.model.HaSubFlow;
 import org.openkilda.model.Switch;
 import org.openkilda.persistence.PersistenceManager;
 import org.openkilda.wfm.error.FlowNotFoundException;
-import org.openkilda.wfm.share.history.model.HaFlowEventData;
 import org.openkilda.wfm.topology.flowhs.exception.FlowProcessingException;
 import org.openkilda.wfm.topology.flowhs.fsm.common.actions.NbTrackableWithHistorySupportAction;
 import org.openkilda.wfm.topology.flowhs.fsm.haflow.update.HaFlowUpdateContext;
@@ -58,7 +57,6 @@ public class UpdateHaFlowAction extends
             HaFlow haFlow = getHaFlow(haFlowId);
 
             log.debug("Updating the flow {} with properties: {}", haFlowId, targetHaFlow);
-            saveNewEventInHistory(stateMachine, haFlow);
 
             // Complete target ha-flow in FSM with values from original ha-flow
             stateMachine.setTargetHaFlow(updateFlow(haFlow, targetHaFlow));
@@ -130,13 +128,4 @@ public class UpdateHaFlowAction extends
     protected String getGenericErrorMessage() {
         return "Couldn't update HA-flow";
     }
-
-    private void saveNewEventInHistory(HaFlowUpdateFsm stateMachine, HaFlow haFlow) {
-        HaFlowHistoryService.using(stateMachine.getCarrier()).saveNewHaFlowEvent(HaFlowEventData.builder()
-                .taskId(stateMachine.getCommandContext().getCorrelationId())
-                .action("Update HA-flow")
-                .event(HaFlowEventData.Event.UPDATE)
-                .haFlowId(stateMachine.getHaFlowId())
-                .build());
-    }
 }
Repository: telstra/open-kilda
Issue: Flow reroute has a wrong message in the flow history

When rerouting a simple flow there is a message in the flow history: HA-flow was validated successfully. 

Steps to reproduce:
1. Create a flow with any parameters
2. Execute a reroute for this flow: `/flows/{id}/reroute`
3. Navigate to this flow's history: `/flows/{id}/history`, find the history event "flow rerouting"

actual result: "action": "HA-flow was validated successfully",
expected result: "action": "Flow was validated successfully"

Changed files:
src-java/flowhs-topology/flowhs-storm-topology/src/main/java/org/openkilda/wfm/topology/flowhs/fsm/reroute/actions/ValidateFlowAction.java

diff --git a/src-java/flowhs-topology/flowhs-storm-topology/src/main/java/org/openkilda/wfm/topology/flowhs/fsm/reroute/actions/ValidateFlowAction.java b/src-java/flowhs-topology/flowhs-storm-topology/src/main/java/org/openkilda/wfm/topology/flowhs/fsm/reroute/actions/ValidateFlowAction.java
index e8ac62995..037ec78f7 100644
--- a/src-java/flowhs-topology/flowhs-storm-topology/src/main/java/org/openkilda/wfm/topology/flowhs/fsm/reroute/actions/ValidateFlowAction.java
+++ b/src-java/flowhs-topology/flowhs-storm-topology/src/main/java/org/openkilda/wfm/topology/flowhs/fsm/reroute/actions/ValidateFlowAction.java
@@ -166,7 +166,7 @@ public class ValidateFlowAction extends
         stateMachine.setAffectedIsls(context.getAffectedIsl());
         stateMachine.setIgnoreBandwidth(context.isIgnoreBandwidth());
 
-        stateMachine.saveActionToHistory("HA-flow was validated successfully");
+        stateMachine.saveActionToHistory("The flow has been validated successfully");
 
         return Optional.empty();
     }
Repository: telstra/open-kilda
Issue: Flow loops: Installing the exact same loop twice leads to deletion of flow loop rules

1. Create a flow
2. Create a flow loop on src
3. Repeat the same request from previous step
**Expected:** Flow loop rules are just re-installed
**Actual:** Flow loop rules are removed. Switch validation shows missing rules

test: `"Attempt to create the exact same flowLoop twice just re-installs the rules"`

Changed files:
src-java/flowhs-topology/flowhs-storm-topology/src/main/java/org/openkilda/wfm/topology/flowhs/fsm/update/actions/UpdateFlowAction.java

diff --git a/src-java/flowhs-topology/flowhs-storm-topology/src/main/java/org/openkilda/wfm/topology/flowhs/fsm/update/actions/UpdateFlowAction.java b/src-java/flowhs-topology/flowhs-storm-topology/src/main/java/org/openkilda/wfm/topology/flowhs/fsm/update/actions/UpdateFlowAction.java
index 922cc4d67..8b820d7b1 100644
--- a/src-java/flowhs-topology/flowhs-storm-topology/src/main/java/org/openkilda/wfm/topology/flowhs/fsm/update/actions/UpdateFlowAction.java
+++ b/src-java/flowhs-topology/flowhs-storm-topology/src/main/java/org/openkilda/wfm/topology/flowhs/fsm/update/actions/UpdateFlowAction.java
@@ -234,10 +234,10 @@ public class UpdateFlowAction extends NbTrackableAction<FlowUpdateFsm, State, Ev
     }
 
     private FlowLoopOperation detectFlowLoopOperation(RequestedFlow originalFlow, RequestedFlow targetFlow) {
-        if (originalFlow.getLoopSwitchId() == targetFlow.getLoopSwitchId()) {
+        if (originalFlow.getLoopSwitchId() == null && targetFlow.getLoopSwitchId() == null) {
             return FlowLoopOperation.NONE;
         }
-        if (originalFlow.getLoopSwitchId() != null) {
+        if (targetFlow.getLoopSwitchId() == null) {
             return FlowLoopOperation.DELETE;
         } else {
             return FlowLoopOperation.CREATE;