PipedreamHQ / PipedreamHQ/pipedream
[BUG] Error when calling airtable_oauth_create_field through MCP
- Dominant language
- JavaScript
- Stars
- 11.7k
- Forks
- 5.8k
- Avg merge
- 3d 10h
- Merged PRs (30d)
- 102
Description
## Describe the bug
The `airtable_oauth-create-field` action expects `baseId` and `tableId` as objects with `label` and `value` properties (when using the UI), but the underlying code in `create-field.mjs` and `common.mjs` only uses the `.value` property. When calling the action programmatically (e.g., via API or automation), passing an object for `baseId` or `tableId` results in a type error:
```
Parameter 'baseId' must be of type string, got object
```
However, if you pass a string, the code attempts to access `.value` on a string, resulting in `undefined` and a failed API call.
---
## To Reproduce
Steps to reproduce the behavior:
1. In Cursor agent mode, attempt to call the `airtable_oauth-create-field` action programmatically, passing `baseId` and `tableId` as objects (e.g., `{ label: "My Table", value: "tblUm5IECM0GPUcjE" }`).
2. Observe a type error:
```
Parameter 'baseId' must be of type string, got object
```
3. Attempt to call the action with `baseId` and `tableId` as strings.
4. The code tries to access `.value` on a string, resulting in `undefined` and a failed API call to Airtable.
---
## Expected behavior
The action should consistently accept either objects (with `label` and `value`) or strings for `baseId` and `tableId`, both in the UI and when called programmatically. The code should handle both cases gracefully, or the documentation should clearly specify the required format.
---
## Screenshots
N/A (error is in code execution and API response)
---
## Desktop (please complete the following information):
- OS: macOS (darwin 24.4.0)
- Browser: Cursor 0.48.9
- Version: using 3.7 Sonnet thinking max in agent mode
---
## Smartphone (please complete the following information):
- Device: N/A
- OS: N/A
- Browser: N/A
- Version: N/A
---
## Additional context
- The relevant code in `create-field.mjs` uses `this.baseId.value` and `this.tableId.value`, which fails if a string is provided.
- The prop definitions in `common.mjs` use `withLabel: true`, which may be causing the UI to pass objects, but the runtime expects strings.
- This inconsistency makes it impossible to use the action programmatically without error.
---
## Potential Solution
Update the code in `create-field.mjs` to handle both string and object types for `baseId` and `tableId`:
```js
// create-field.mjs
// ... existing code ...
async run({ $ }) {
const {
description, name, options, type,
} = this;
// Handle both string and object for baseId/tableId
const getId = (id) => (typeof id === "object" && id !== null ? id.value : id);
const response = await this.airtable.createField({
baseId: getId(this.baseId),
tableId: getId(this.tableId),
data: {
name,
type,
description,
options: typeof options === "string"
? JSON.parse(options)
: options,
},
$,
});
if (response) {
$.export("$summary", `Successfully created field with ID ${response.id}.`);
}
return response;
},
// ... existing code ...
```
This change ensures compatibility with both UI and programmatic usage.
Contributor guide
Assessment
This issue has not been assessed yet.