Airtable TypeCast Not Working

Describe the problem/error/question

Hello engineers, I have an airtable node with a field of type select. However when I pass data through this field yet it was not in the options field in, the value cannot be added in Airtable options.

What is the error message (if any)?

ERROR: Invalid input for 'status' [item 0]

'status' expects one of the following values: [Open, In Progress, In Review, Completed] but we got 'Type Cast Trial'

Note

I have enabled Typecast in my airtable node
Below is a screenshot of the node and the error

Hey @Anton_Odongo,

That looks like Airtable is saying the status field can only contain one of the following values.

  • Open
  • In Progress
  • In Review
  • Completed

But the node is sending Type Cast Trial it sounds like it might just need to be updated in Airtable or there might be a delay between adding the option and it being available to the API.

Hello all,
I am getting the same problem.

Could the problem be related to the airtable node missing the schema.bases:write scope?

The airtable node contains only:
const scopes = ['schema.bases:read', 'data.records:read', 'data.records:write'];

Hey @bastienperez,

Welcome to the community :cake:

It doesn’t appear to be a scope issue the error from Airtable is saying thre is a field value being sent that is unexpected.

Can you share the error you are getting and a screenshot of the data you are sending?

You are right, it is not scope related.

I saw another topic with this issue (Airtable Typecast is not working - #9 by peterng1618) and I think I understand what the problem is, it’s due to the node expecting a value in the options field.

To fix this on my workflow, I downloaded the workflow json, change the line related to my Select field from options to string and it works:
"type": "options", -> "type": "string",

I don’t know if my workaround makes sense? Maybe n8n has another way to do this?

Ahhh so in your case it could be that the field was updated in airtable but we didn’t pick it up in the component.

I still need to test that one.

The option doesn’t exist in Airtable at first, the use case is I want n8n to create a record with a brand new option.
Changing Options > String does the trick, but I don’t know if there is another workaround.

This is how I hacked it . Couldn’t find a better option though.

1 Like

It looks like this continues to be a bug. The issue is not on the Airtable side (it never gets there), but in the n8n validation of the new option.

The typecast option should allow you to add a new option to a select field at the same time as you create/update a record. If the available options for a select field are:

{
  "id": "Animal",
  ...
  "type": "options",
  "options": [
    {
      "name": "Dog",
      "value": "Dog"
    },
    {
      "name": "Cat",
      "value": "Cat"
    }
  ],
  ...
  }

Creating/update a record with typecast: true should allow you to create a new record with Animal = Moose. The issue is that n8n does not think that is a valid option, getting the error:

'Animal' expects one of the following values: [Dog, Cat] but we got 'Moose'

ExpressionError: Invalid input for 'Animal' [item 0]
    at validateValueAgainstSchema (/usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/node-execution-context/utils.js:144:15)
    at ExecuteContext._getNodeParameter (/usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/node-execution-context/node-execution-context.js:188:61)

I’m not sure if it’s possible in n8n to dynamically add the new option before validation. But it seems like a few potential solutions:

  • Dynamically add the new option as a valid option when typecast=true
  • Ignore option validation when typecast=true
  • Do a separate call to add the select option to the field.

The reason changing the type to string works is because it skips this validation.

1 Like

Hi all, jhand is correct and this is a bug with n8n. The native Airtable integrations is a mess and I recommend keeping things simple and not using it.

New version [email protected] got released which includes the GitHub PR 14726.

how can we active this? still doesn’t work.