# Troubleshooting Flows

## General

* For more complex Flows and errors we highly recommend to have the Flow Builder and Flow Debugger opened in multiple browser tabs to be able to quickly (without loading) jump between:
  * Different runs (e.g. to compare why something worked in one run, but didn't in another)
  * Flow Builder and Flow Debugger (e.g. to check the exact step configuration of a step that's currently opened in the Flow Debugger)
* If the Response code is `N/A` for a non-Helper (besides [REST Helper](https://docs.locoia.com/connectors/helpers/rest-helper)) step, then the issue most likely lays somewhere within the Flow (or you discovered a Locoia bug)
  * Thus, if a step has a status code and it looks like you made the request correctly, the issue lies most likely somewhere on the third party's side

## Common errors

### Invalid syntax errors

#### Error

Errors like:

> invalid syntax. Perhaps you forgot a comma? (\<unknown>, line 13501)

Are quite difficult to pinpoint and troubleshoot by it's own, as one doesn't easily know where the provided line number is.

#### Solution

1. Click **Download entire input** in the Flow Debugger
2. Run this command in the terminal while you're in the directory of the downloaded file: `sed -i '' -e '1s/^{"expression":"//' -e '$s/"\}$//' -e 's/\\"/"/g' -e 's/False/false/g' -e 's/True/true/g' -e 's/None/null/g' -e 's/\\n//g' filename`
   1. `filename` needs to be replaced with the actual filename
   2. This will make all the needed replacements for a valid JSON within a second or so
3. Then open the file in a code editor
4. Turn "Word Wrap" on, and do the JSON formatting, which will point out the error nicely

### Flow step cancellation

Flow steps may be canceled (Flow run status: `error`) due to specific conditions. Below are the categories of failures and their corresponding messages:

***

#### **1. Step Input Limit**

If the input size for a step exceeds the default limit (100 MB), the following error is raised:

```
Input size exceeds the limit of 100 MB.
```

***

#### **2. Timeouts**

If a step **times out** during execution (default is **15 seconds**), the following message is shown:

```
Step has been automatically cancelled due to timeout.
```

**Possible Causes**:

* A **slow API** is being called
* An **infinite loop** in Jinja code

***

#### **3. Step Output Limit**

The **Step Output Limit** enforces restrictions on the size of the data that a step during Flow execution can return. Depending on the feature settings and the connector type, there are two possible scenarios:

{% hint style="warning" %}
The **Step Output Limit** will soon be **enabled for all accounts** to prevent unexpected errors caused by processing large step output data. Customers are encouraged to proactively modify their Flows to handle smaller chunks of data.
{% endhint %}

1. **Step Output Size Exceeded (Feature Enabled)**\
   \
   If the Step Output Limit feature is **enabled** for the user's company, and the step output size exceeds the default limit (**50 MB**), the following error message is displayed:<br>

   ```
   Your flow execution was terminated due to the fact 
   that your output step data ({readable_response_step_size}) 
   exceeded the current limit set for your account, {readable_locoia_step_size_limit}. 
   Please modify your flow logic to utilize smaller chunks of data. 
   If the problem persists do not hesitate to contact support.
   ```

   **Implications**:

   * The **Flow** is marked as "Error" in the debugger.
   * The **Step** is marked as "Error," and users must inspect the step output for details.

   **Action for Users**:

   * Adjust the Flow logic to ensure smaller chunks of data are processed in each step.
   * Contact support if the issue persists.
2. **Step Output Size (Feature Disabled or Connector = Looper)**\
   \
   If the Step Output Limit feature is **disabled** or the step uses the **Looper** connector, the step size is **not enforced**. In this case, the Flow proceeds, but it may result in unexpected behavior.

A **warning** is logged for debugging purposes:

```
Flow step exceeded step size limit. Flow ID {flow_id}, Company ID: {id}, 
Connector Name: {name}, Connector ID: {id}, Step Size: X bytes"
```

***

#### **4.** Processing Failure (Stuck Step)

When the step request cannot be processed at all, the following message is shown:

```
Step has been automatically canceled because we couldn't
process it after retrying it a few times. This most likely
happened because you try to process a lot of data (more than 100MB
or more than that are created in the process) or the third party API
responds very slowly. If none of these apply and you can't
resolve this issue, please contact Locoia support.
```

**Possible Causes**:

* Processing a large amount of data (over the memory limit).
* A slow response from a third-party API.
