> For the complete documentation index, see [llms.txt](https://docs.appfarm.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.appfarm.io/reference/appfarm-client/warnings-and-errors.md).

# Warnings and errors

There are a range of warnings and errors that you may encounter in the [developer tools](/reference/appfarm-client/developer-tools-for-apps.md) while debugging your apps.

## Warnings

Warnings are notices which you should review. You should potentially take action if your app is suffering from degraded performance.

### Running full formula recalculation on Self after just recalculated all formulas

This warning occurs when an Update/Create/Delete or Set Selection action node has been run, forcing another data source to recalculate one of its runtime properties (function properties), a short time after it was last done.

**Example**: Data source `Order` has a runtime property `Is transferred` (a function, returning `true`if the property `Transferred Date has value`). An action updates `Transferred Date` twice. This warning will appear.

{% hint style="success" %}
This warning can be ignored in most cases. It might be worth investigating if you notice a performance issue when recalculating formulas (runtime properties as functions) on large data sources.
{% endhint %}

### Replaced data in dataSource, but did not recalculate dependencies

This warning is typically seen when performing web requests and a mapped data source is populated with data. The populated data source is runtime only, and when this is populated using a web request, an optimization is in place to ensure that potential dependencies are not recalculated. A dependency in this case is a *deep data binding.*

**Example:** A web request populates data source `Orders (runtime)`. If you try to display `Orders (runtime).Customer.Name` in a view, `Customer.Name` will not be updated when `Orders (runtime)` is repopulated. However, if you add `Customer` as a [reference data source](/reference/apps/data.md#reference-data-sources) on the `Orders (runtime)`, you can safely reference `Orders (runtime).Customer.Name`.

{% hint style="success" %}
This warning could be ignored in most cases. If you are using deep data bindings on the populated data source, make sure to utilize [reference data sources](/reference/apps/data.md#reference-data-sources).
{% endhint %}

### The created object does not match the filter of the Data Source it was created in

This warning appears when you have a Filter on a Database Connected Data Source, and you perform a Create Object into it - but the created object does not match the filter of the Data Source. The object is successfully created, but is then immediately removed from the Data Source.

**Example**: A Data Source `Open Tickets` with filter `Ticket.Status = Open`. A Create Object creates a new Ticket into this Data Source, but the `Status` is set to `Completed`. Thus, a Completed ticket is created into the database, but that completed Ticket does not exist in the Data Source `Open Tickets`.

## Errors

### **Create object failed - Cannot create object in non-empty dataSource with cardinality one**

This error occurs when you have a runtime-only data source with cardinality one. You try to create a new object in the data source, but an object already exists in the data source.

**Example**: You have an action `Create project` creating a new Project in the data source `Project (runtime)`. It works the first time, but fails the second time.

{% hint style="success" %}
There are two ways to solve this issue:

\
**Option 1 (recommended):** In the **Create Objects** action node, select the **Replace Existing Object** checkbox.

**Option 2**: Use a **Delete Objects** action node on the runtime data source before running the **Create Objects** action node.
{% endhint %}

### AuthorizationError: Missing required permissions to...

The following errors may occur when creating or updating user accounts from an app.

* AuthorizationError: Missing required permissions to assign roles
* AuthorizationError: Missing required permissions to delete roles
* AuthorizationError: Missing required permissions to update account
* AuthorizationError: Missing required permissions to create account

These errors indicate that the logged-in user's role(s) do not have sufficient privileges to perform the operation. When performing user account operations in an app, Owners, Maintainers, and Developers role privileges are not valid.

{% hint style="success" %}
Go to **Permissions** > **Accounts/Roles** to verify that you have the correct permissions in place. Note that your own user must be member of a custom role in order to create, update or delete users from an app - even in the Development environment. Also, verify that create, update or delete users is [enabled for the environment](/reference/configuration/environments.md#user-account-manipulation) under **Environments***.* Read more [here](/how-to/authentication-and-access-control/add-users-assign-roles.md#enable-which-role-may-update-or-create-user-accounts).
{% endhint %}

### **EnvironmentAuthorizationError - User Accounts accounts cannot be updated from current environment - Check Environment settings**

The same cause also applies to the following error messages:

* User Accounts accounts cannot be created from current environment - Check Environment settings
* User Accounts accounts cannot be deleted from current environment - Check Environment settings.

These errors can occur in the Development, Test or Staging environments.

[User](/reference/security/users.md) accounts are global resources and changes to user accounts in any environment will affect production. To prevent unintended user changes, [user account manipulation](/reference/configuration/environments.md#user-account-manipulation) operations are disabled by default in Development, Test, and Staging. Additionally, the settings are automatically reset every night.

{% hint style="success" %}
Verify that create, update or delete users is [enabled for the environment](/reference/configuration/environments.md#user-account-manipulation) under **Environments***.*
{% endhint %}

### ForEach: Unable to find dataSource for iteration

A [Foreach action node](/library/action-nodes/foreach.md) is missing a value for the **Selection** propert&#x79;*.* This error can also be seen in Appfarm Create with a red dot on the property.

{% hint style="success" %}
Set a valid value in the **Selection** property of the Foreach action node such as **All objects**, **Selected object(s)** or **Filtered selection***.*
{% endhint %}

### InvalidEmailError: Email for validation is Nil

A [Send email action node](/library/action-nodes/send-email.md) has an invalid **Recipient** property.

**Example:** You read data into a `User (runtime)` data source, resulting in 0 objects. You try to run Send email with the recipient `User (runtime).Email.`

{% hint style="success" %}
Your business logic is not set up correctly. Make sure the data source selected in the **Recipient** property contains an object, and that the email property of this object has a value.
{% endhint %}

### No objects found for deletion

A [Delete objects action node](/library/action-nodes/delete-objects.md) results in no objects being deleted, since either the data source is empty, or the [filter](/reference/platform-concepts/filters.md) expression results in no objects for deletion.

It might also be that you have a [Delete objects action node](/library/action-nodes/delete-objects.md) using **Selected object(s)**, and the data source has no selected objects.

{% hint style="success" %}
Your business logic is not set up correctly. Make sure the Delete objects action node has a valid filter or selection.
{% endhint %}

### Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource

This error occurs when you have a [Web request action node](/library/action-nodes/web-request.md) with **Send from Client** selecte&#x64;*.* When using send from client, the browser's CORS (Cross-Origin Resource Sharing) policies are triggered.

{% hint style="success" %}
The recipient of the web request (the other application) needs to add \*.appfarm.app (or your custom domain, if applicable) to their list of accepted domains in their 'Access-Control-Allow-Origin' settings.
{% endhint %}

### SimpleWebRequest Error: Invalid mapping - non-integer path for Array

A [Web request action node](/library/action-nodes/web-request.md) returns an array of objects, and the result mapping is not set up correctly.

{% hint style="success" %}
In **Result Mapping**, to map all objects from the response, make sure to set the **Data Source** property to a runtime-only data source with cardinality *Many*. If you receive an array of objects and only want to map the first item, you can use dot notation to access the first object, for example Orders.0.OrderNumber to only map the order number of the first order. See [Web request](/library/action-nodes/web-request.md) for more information.
{% endhint %}

### **Invariant failed**

This error message is related to drag-and-drop.

{% hint style="success" %}
Make sure any [drag-and-drop](/how-to/user-interface/drag-and-drop.md) functionality is configured correctly.
{% endhint %}

### Error running function: Cannot read properties of undefined (reading 'length')

Functions may exist in Runtime Properties in App Data, inside an Action (e.g a Condition) or in User Interfaces.

If this error message e.g. appears in a Persist Action Node, it's probably caused by a Runtime Only Property (Function) on a Data Source. If it appears just when navigating to a View, it's caused by a function (calculated text, visible condition etc.) inside that View.

**Example**: A function `return companies[0].name` can give this error message: What if `companies` is an empty list? Then this function will fail with this error message. The function should handle this scenario and be set up such as this: `if (companies.length>0) return ...`

{% hint style="success" %}
Go through Runtime Properties (Functions) on your Data Sources. If this message occurs when the App loads, it's probably related to a Database Connected Data Source. Check for functions which could result in errors, and handle this by adding IFs as in the above example.
{% endhint %}

### Object or array was returned in function value. Expected primitive type

This error occurs when a Function returns a data type which is not a simple data type. A simple data type is an Integer, Boolean, String, Float, ID etc. Typically, this occurs when the function returns an Object or an Array.

**Example:** An Update Object Action Node updates a Datetime property using the following function:

```
let myDate = moment().add(2,'days')
return myDate
```

`myDate` is an Object of type moment, and not a simple data type. In the example above, the Function should return a Datetime data type.

**Solution**: The return value needs to be changed to a simple data type. In this case, the moment.js library has a toJSON() method that converts it to a Datetime.

```
let myDate = moment().add(2,'days')
return myDate.toJSON()
```

{% hint style="success" %}
This issue is solved by converting the return value of the function to a simple data type. In many cases, the issue is that you are returning an object, and you may often apply `.toJSON()` to the return value.
{% endhint %}

### Proxy error / ECONNREFUSED

This error message may occur when trying to access an App, the GraphQL Editor (`https://<yoursolution>.appfarm.app/api/graphql/`) or Swagger (the Services tool found in `https://<yoursolution>.appfarm.app/api/services/`).

The most frequent occurrence of this error is in the Dev-client for your Apps (when testing your App in Develop environment), and you have a large solution. In this case, the auto-deploy may cause a minor delay for the Dev-client to reload. The issue should only last for a few seconds. The exact same issue may occur for the Swagger client when testing your Services in the Dev environment.

{% hint style="success" %}
This issue normally resolves itself after 5-30 seconds
{% endhint %}

This error may also occur in a Prod environment when not sufficient resources are available. For example, if one or more performance-heavy services are running, and the auto-scaling has reached its limit. A solution to this may be to improve the performance of the Service ([optimize ](/how-to/security-testing-and-deployment/optimize-your-app.md)it) or to adjust the Schedule (if more Services are running in parallel). It might be that the limits should be adjusted as well if there is nothing to optimize (Appfarm needs to be contacted).

Example error messages:

* `Proxy error` (only): This may occur when the client is suspended or disabled. For example, if your solution has been suspended and the Dev client is disabled.
* `{"code":503, "message":"Proxy error - service", "err":{"errno":-111, "code":"ECONNREFUSED","syscall":"connect","address":"NN.NN.NNN.NN", "port":5000}}`
* `{"code":503, "message":"Proxy error - client unavailable", "err":{"errno":-111, "code":"ECONNREFUSED","syscall":"connect","address":"NN.NN.NNN.NN", "port":5000}}`

### Proxy error - api-service unavailable

This error occurs if you have not enabled API Services from [Environment Config](/reference/configuration/environments.md#general-settings), and you try to access [Service Developer Tools](/reference/appfarm-client/developer-tools-for-services.md), or try to execute a Service Endpoint from a third-party tool or schedule.

{% hint style="success" %}
Go to [Environment Config](/reference/configuration/environments.md#general-settings) and tich **Enable API Services**.
{% endhint %}

### Navigate - Could not find specified view / Could not find specified subview

These errors are usually caused by one of these reasons.

* The action tries to open a view that does not exist. This can be caused by a typo in a data bound viewId or an inconsistency between actual views and the navigate action node.
* The View exists, but is not loaded since it is corrupt and contains an error causing the parsing and inflation of the view to fail. These parsing errors should be shown in Dev Tools from the App Validation menu.
* The navigate is run in an On App Load event handler, and is run prior to the client receiveing all metadata. Note that the On App Load event is run after the App has loaded app description, data model, actions, functions and initial data, but *prior* to loading *all* layout / views.

### Eval timeout - function took too long to execute (FunctionEvalTimeoutError)

This error may be seen in Apps, but is more typical in Services.

Evaluation and calculation of functions has a execution limit of 2000 milliseconds. That applies to e.g. a Result Parser in a Web Request, an If-statement using the Function Editor, or a Runtime Property or Object Class Property of type Function.

{% hint style="success" %}
If you have a single function or result parser consuming more than 2000 ms, you need to optimize the function, or process smaller amounts of data inside it.
{% endhint %}

### Error - At least one object for modification is not in the datasource

This error typically occurs in Development environments when performing Update Object on Database Connected Data Sources, and there is an inconsistency between the data source content on the client ("in the App") and on the server. When developing in Appfarm Create, the client tries automatic deploy of all "UI related changes". But whenever a change is done on the data level (a new data source, a new object class property put in use in your UI), you will need to **manually refresh your development client to get new data**. Otherwise, errors such as this may occur.

### CastError: Cast to ObjectId failed for value ...

This error is caused by inconsistencies in the data, which may occur in the cases where old data is stored in column names previously deleted, but now "re-established" with a new datatype.

Read more about how to debug and fix this issue in the Debugging Data Issues section [here](/how-to/security-testing-and-deployment/test-and-debug.md#debugging-data-issues).

### Action Node failed: Persist Objects -> MongoServerError: WriteConflict error

Full error message:

`Action Node failed: Persist Objects -> MongoServerError: WriteConflict error: this operation conflicted with another operation. Please retry your operation or multi-document transaction.`

A write conflict occurs when two operations try to write to the same object in the database at the same time. The database does not queue the second write. While one transaction holds an object, any other write to that object fails immediately.

#### Why it happens

* **Locks apply to the whole object, not individual properties.** Two saves of the same object collide even if they change completely different properties. (When an object is persisted, every property read into the runtime object is saved, changed or not. Apps only read the properties in use, while services read all properties on the object class. Since the lock covers the whole object, this does not affect whether a conflict occurs.)
* **A batch persist is one transaction.** When [Persist objects](/library/action-nodes/persist-objects.md) saves many objects, they are written one after another inside a single transaction. Every object stays locked until the whole transaction commits, so a large batch can hold its objects for a noticeable amount of time.
* **A failed batch is rolled back in full.** If one object in the batch conflicts, none of the objects in the batch are saved.
* **First writer wins, per object.** For a single object, the operation that gets there first succeeds and the other fails. In a burst of writes against overlapping objects, you will typically see failures on both sides. Single saves fail on objects the batch already holds, and the batch fails (and rolls back) on an object a single save completed first.

#### Typical scenario

A scheduled service persists a large batch of objects, spanning seconds. While this transaction runs, an external system calls a service endpoint, for example a webhook delivering status callbacks, which updates one of the same objects. Whichever transaction reaches a shared object second fails.

Other common causes:

* The same service endpoint is triggered in parallel by multiple callers.
* Parallel execution in a [Foreach](/library/action-nodes/foreach.md) or [Block](/library/action-nodes/block.md) action node persists overlapping objects.
* Several services, flows or schedules update the same object class at the same time.

#### What does not solve it (but may improve it)

* **Retrying.** Retrying only helps with occasional, short collisions. If the other writer holds the objects for a while, or new writes keep arriving, the retry hits the same conflict.
* **Persisting one object at a time.** This makes each conflict smaller but does not remove it. Many parallel single-object saves also queue up on the database connections, which slows the solution down.
* **Smaller batches or delays.** These reduce how often conflicts happen, but do not eliminate them.

{% hint style="success" %}
The fix is to make sure that **only one process writes to a given object at a time**.

**Option 1 (recommended): Queue incoming updates.** Do not let the second writer, for example a webhook endpoint, update the object directly. Let it only *create* a new object in a separate object class, for example `Delivery Report`, with a reference to the target object and a `Processed` flag. Creating new objects never conflicts. The process that owns the target objects, for example the scheduled service, then reads the unprocessed entries, applies them to the target objects, and marks them as processed. This leaves a single writer on the target object class.

**Option 2: No Concurrency.** If the conflicts come from the *same* service endpoint being triggered in parallel, select **No Concurrency** on the [service endpoint](/reference/services/service-endpoints.md). This does not help when the conflicting writes come from different endpoints, services, flows or apps.

For rare, unavoidable collisions, use a [Catch exception](/library/action-nodes/catch-exception.md) action node to handle the error, and consider logging it as described in [Event log design](/how-to/logic-and-flow/event-log-design.md).
{% endhint %}

### Unable to load initial data for app (RequestTimeoutError)

This error message occurs if too much data is read for the database connected data sources defined for your app, or if you have circular dependencies in your App Data filters.

An example of the first scenario (too much data): You have a data source `Orders` with filter `Read All`, and 10.000.000 orders exist in the database. This amount of records will not be able to load before a timeout is encountered. You must limit the amount of data read into one or more of the data sources. Please see [this article](/how-to/security-testing-and-deployment/test-and-debug.md#debugging-data-issues) for information on debugging data issues.

An example of the second scenario (circular dependencies): You have a data source `Orders` and a data source `Companies`. `Orders` has a filter `Company exists in Companies.ID`, and `Companies` has a filter `ID exists in Orders.Company`. None of them may be read first since both are waiting for each other. These kinds of issues should be detected by the [App Health](/reference/apps/app-health.md) tool.

### DocumentLimitExceededError: Cannot create document(s)

```
DocumentLimitExceededError: Cannot create document(s). 
This would exceed the maximum limit of 10000 documents for Object Class...
```

This error may occur on free tier / free sandboxes. The maximum number of objects stored in an object class is limited. This limit may be increased by the Appfarm team on demand. No such limit exists in paid tiers.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.appfarm.io/reference/appfarm-client/warnings-and-errors.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
