Grist API Incident: 'IsFormula = False' failure and data corruption

Hello, I need help with a technical issue in Grist. I was setting up a trigger formula column in Grist. My code was working well in formula mode (IsFormula = True). However, when I switched IsFormula to False to set it as a trigger formula, I encountered an error stating: “Error manipulating data: [Sandbox] TypeError ‘AltText’ object is not iterable.” Following this, my file seems corrupted, and all previously functioning API requests now generate the same error. How can I make IsFormula = False be accepted without causing errors?

import requests
import json

# Configuration
API_KEY = " ?"
DOC_ID = " ?"
TABLE_NAME = " ?"
BASE_URL = f"https://grist.?.net/api/docs/{DOC_ID}/tables/{TABLE_NAME}"

headers = {
    "Authorization": f"Bearer {API_KEY}",
    "Content-Type": "application/json"
}

def test_create_complex_column():
    # Creating a more complex column to test the API
    payload = {
        "columns": [
            {
                "id": "test_time_logs",
                "fields": {
                    "type": "Date",
                    "isFormula": True,  # Use True to indicate this is a formula column
                    "formula": "NOW()",  # Formula to execute under specific conditions
                    "label": "Test Time Logs",
                    "recalcWhen": 0,
                    "recalcDeps": [
                        "L",
                        7
                    ]
                }
            }
        ]
    }
    
    # Sending the POST request
    response = requests.post(f"{BASE_URL}/columns", headers=headers, data=json.dumps(payload))
    if response.status_code == 200:
        print("Column created successfully:", response.json())
    else:
        print("Failed to create column:", response.status_code, response.text)

# Run the function to create a more complex column
test_create_complex_column()

Could you share your formula (that used to be a regular formula, and now is a trigger formula)? Also the type of the column would be relevant.

I don’t see anything wrong in the code you pasted, but I am not sure how it relates to your question.

I apologize if my question was unclear. I am looking to create a trigger formula (which is a simple NOW() )that reacts when data in column 7 are updated or added. Currently, I am using a formula that captures the date of the update, but it is not a trigger formula. When I change the IsFormula setting to false to convert this into a trigger formula, I encounter an error. Could you help me resolve this issue?

below the code who doesn’t work :

import requests
import json

# Configuration
API_KEY = " ?"
DOC_ID = " ?"
TABLE_NAME = " ?"
BASE_URL = f"https://grist.?.net/api/docs/{DOC_ID}/tables/{TABLE_NAME}"

headers = {
    "Authorization": f"Bearer {API_KEY}",
    "Content-Type": "application/json"
}

def test_create_complex_column():
    # Creating a more complex column to test the API
    payload = {
        "columns": [
            {
                "id": "test_time_logs",
                "fields": {
                    "type": "Date",
                    "isFormula": False,  # Use False to indicate this is a trigger-formula 
                    "formula": "NOW()",  # Formula to execute under specific conditions
                    "label": "Test Time Logs",
                    "recalcWhen": 0,
                    "recalcDeps": [
                        "L",
                        7
                    ]
                }
            }
        ]
    }
    
    # Sending the POST request
    response = requests.post(f"{BASE_URL}/columns", headers=headers, data=json.dumps(payload))
    if response.status_code == 200:
        print("Column created successfully:", response.json())
    else:
        print("Failed to create column:", response.status_code, response.text)

# Run the function to create a more complex column
test_create_complex_column()

Does the error occur when you run the code you share? I.e. does your print trigger about “Failed to create column”? If so what’s the error?

If not, is the error in a cell in the column? When does it appear? Do you see the error when you create this trigger column manually through the UI, rather than through your script? Can you share any screenshots of the error, and of the column configuration?

Hello, yes, it is the code from my response that I am running (with the parameter IsFormula = False to create a trigger formula column). This doesn’t trigger the “Failed to create column” error, but instead, I get the following error: “Error manipulating data: [Sandbox] TypeError ‘AltText’ object is not iterable.” After this, any API request that previously worked no longer functions and always returns the same error: “Error manipulating data: [Sandbox] TypeError ‘AltText’ object is not iterable.” I encounter the same error when trying to make any modification, even manually (I am forced to reload a previous version).

The error is global and appears across the entire database. In general, the columns generated with the formula (functional, meaning with IsFormula = True) are also buggy because they cannot be deleted, with an error message as well.

Here’s the solution I found: it was due to a misconfiguration of “recalcDeps”. I had set it to json.dumps(["L", 7]) instead of "[7]". Now everything is working fine. Thanks everyone for your help!

1 Like