Skip to content

Fix: pass returnFieldsByFieldId to getRecord for Airtable actions #16391

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

SokolovskyiK
Copy link
Contributor

@SokolovskyiK SokolovskyiK commented Apr 22, 2025

Fixes #16317

I opened both actions:

get-record.mjs

get-record-or-create.mjs

Both use the shared getRecord() method from commonActions.mjs.

I noticed that returnFieldsByFieldId was not being passed to the API when fetching a record — unlike updateRecord(), which correctly includes it via the opts parameter:

updateRecord({
  baseId,
  tableId,
  recordId,
  data: record,
  opts: {
    returnFieldsByFieldId: ctx.returnFieldsByFieldId,
  },
});

I inspected getRecord() and found the issue:

getRecord({
  baseId,
  tableId,
  recordId,
}) {
  const base = this.base(baseId);
  return base(tableId).find(recordId); // ❌ No support for opts
}

I suspected .find() might not support query parameters, so I checked the Airtable SDK (table.ts) and confirmed:

this.find = callbackToPromise(this._findRecordById, this);
this.update = callbackToPromise(this._updateRecords.bind(this, false), this);

These wrap two different functions:

    .update() wraps _updateRecords(..., opts, callback) 

    .find() wraps _findRecordById(recordId, callback) 

Since _findRecordById does not accept opts, and .find() simply wraps it, there's no way to pass returnFieldsByFieldId using the SDK method.

What I did to fix it

I rewrote the internal getRecord() method inside the Airtable app (airtable_oauth.app.mjs)
to use this._makeRequest() instead of .find(), giving us full control over query parameters:

    getRecord({
  baseId,
  tableId,
  recordId,
  opts = {},
}) {
  return this._makeRequest({
    method: "GET",
    path: `/${baseId}/${tableId}/${recordId}`,
    params: opts,
  });
}

Then I updated commonActions.getRecord(...) to pass the returnFieldsByFieldId flag properly:

const response = await ctx.airtable.getRecord({
  baseId,
  tableId,
  recordId,
  opts: {
    returnFieldsByFieldId: ctx.returnFieldsByFieldId, // ✅
  },
});

I also updated get-record.mjs to explicitly expose the returnFieldsByFieldId option to the user by adding it as a prop.

I did not need to modify get-record-or-create.mjs, as it already defined the returnFieldsByFieldId prop and passed this to commonActions.getRecord(...).

Result

When testing the updated actions, I confirmed that:

With returnFieldsByFieldId: true, the response returned field IDs in the fields object

With it disabled, it returned field names as expected

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Added support for specifying which fields to return when retrieving a record from Airtable, allowing more control over the data returned.
  • Refactor

    • Improved internal handling of Airtable API requests for better consistency and maintainability.
  • Chores

    • Updated version numbers across multiple actions and sources to ensure component currency and stability.

Copy link

vercel bot commented Apr 22, 2025

@SokolovskyiK is attempting to deploy a commit to the Pipedreamers Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

coderabbitai bot commented Apr 22, 2025

Walkthrough

The changes update the Airtable OAuth "Get Record" action by adding a new returnFieldsByFieldId property to its props and incrementing its version. The Airtable app's getRecord method was refactored to replace the Airtable SDK call with a direct HTTP GET request that supports an optional opts parameter for query options. The common actions logic was updated to forward the returnFieldsByFieldId option from the action context to the Airtable app's getRecord method. No changes were made to the core logic or error handling.

Changes

File(s) Change Summary
components/airtable_oauth/actions/get-record/get-record.mjs Added returnFieldsByFieldId prop; updated version from 0.0.11 to 0.0.12.
components/airtable_oauth/airtable_oauth.app.mjs Refactored getRecord to use direct HTTP GET request instead of Airtable SDK; added opts parameter.
components/airtable_oauth/common/actions.mjs Updated getRecord to forward returnFieldsByFieldId option from context to Airtable app method.
components/airtable_oauth/actions/* Incremented version numbers in multiple actions with no logic changes (e.g., create-comment, create-field, etc.).
components/airtable_oauth/sources/* Incremented version numbers in multiple sources with no logic changes.
components/airtable_oauth/package.json Updated package version from 0.4.4 to 0.4.5.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant GetRecordAction
    participant CommonActions
    participant AirtableApp

    User->>GetRecordAction: Invoke with returnFieldsByFieldId
    GetRecordAction->>CommonActions: Call getRecord(ctx)
    CommonActions->>AirtableApp: getRecord({ baseId, tableId, recordId, opts: { returnFieldsByFieldId } })
    AirtableApp->>AirtableApp: Make HTTP GET request with query param
    AirtableApp-->>CommonActions: Return record data
    CommonActions-->>GetRecordAction: Return record data
    GetRecordAction-->>User: Return record data
Loading

Assessment against linked issues

Objective Addressed Explanation
Add returnFieldsByFieldId prop to get-record action and ensure it is forwarded to Airtable API (#16317)

Suggested labels

ai-assisted

Suggested reviewers

  • GTFalcao

Poem

A bunny hopped to Airtable’s door,
“Return fields by ID, and nothing more!”
With props aligned and logic tight,
Now fetching records works just right.
The SDK’s gone, HTTP’s in—
This rabbit grins: let flows begin!
🐇✨

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

components/airtable_oauth/actions/create-multiple-records/create-multiple-records.mjs

Oops! Something went wrong! :(

ESLint: 8.57.1

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs
at packageResolve (node:internal/modules/esm/resolve:839:9)
at moduleResolve (node:internal/modules/esm/resolve:908:18)
at defaultResolve (node:internal/modules/esm/resolve:1038:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:557:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:525:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:246:38)
at ModuleJob._link (node:internal/modules/esm/module_job:126:49)

components/airtable_oauth/actions/create-field/create-field.mjs

Oops! Something went wrong! :(

ESLint: 8.57.1

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs
at packageResolve (node:internal/modules/esm/resolve:839:9)
at moduleResolve (node:internal/modules/esm/resolve:908:18)
at defaultResolve (node:internal/modules/esm/resolve:1038:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:557:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:525:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:246:38)
at ModuleJob._link (node:internal/modules/esm/module_job:126:49)

components/airtable_oauth/actions/delete-record/delete-record.mjs

Oops! Something went wrong! :(

ESLint: 8.57.1

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs
at packageResolve (node:internal/modules/esm/resolve:839:9)
at moduleResolve (node:internal/modules/esm/resolve:908:18)
at defaultResolve (node:internal/modules/esm/resolve:1038:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:557:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:525:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:246:38)
at ModuleJob._link (node:internal/modules/esm/module_job:126:49)

  • 20 others

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f0e4b04 and 765691c.

📒 Files selected for processing (24)
  • components/airtable_oauth/actions/create-comment/create-comment.mjs (1 hunks)
  • components/airtable_oauth/actions/create-field/create-field.mjs (1 hunks)
  • components/airtable_oauth/actions/create-multiple-records/create-multiple-records.mjs (1 hunks)
  • components/airtable_oauth/actions/create-or-update-record/create-or-update-record.mjs (1 hunks)
  • components/airtable_oauth/actions/create-single-record/create-single-record.mjs (1 hunks)
  • components/airtable_oauth/actions/create-table/create-table.mjs (1 hunks)
  • components/airtable_oauth/actions/delete-record/delete-record.mjs (1 hunks)
  • components/airtable_oauth/actions/get-record-or-create/get-record-or-create.mjs (1 hunks)
  • components/airtable_oauth/actions/list-records-in-view/list-records-in-view.mjs (1 hunks)
  • components/airtable_oauth/actions/list-records/list-records.mjs (1 hunks)
  • components/airtable_oauth/actions/search-records/search-records.mjs (1 hunks)
  • components/airtable_oauth/actions/update-comment/update-comment.mjs (1 hunks)
  • components/airtable_oauth/actions/update-field/update-field.mjs (1 hunks)
  • components/airtable_oauth/actions/update-record/update-record.mjs (1 hunks)
  • components/airtable_oauth/actions/update-table/update-table.mjs (1 hunks)
  • components/airtable_oauth/package.json (1 hunks)
  • components/airtable_oauth/sources/new-field/new-field.mjs (1 hunks)
  • components/airtable_oauth/sources/new-modified-or-deleted-records-instant/new-modified-or-deleted-records-instant.mjs (1 hunks)
  • components/airtable_oauth/sources/new-modified-or-deleted-records/new-modified-or-deleted-records.mjs (1 hunks)
  • components/airtable_oauth/sources/new-or-modified-field/new-or-modified-field.mjs (1 hunks)
  • components/airtable_oauth/sources/new-or-modified-records-in-view/new-or-modified-records-in-view.mjs (1 hunks)
  • components/airtable_oauth/sources/new-or-modified-records/new-or-modified-records.mjs (1 hunks)
  • components/airtable_oauth/sources/new-records-in-view/new-records-in-view.mjs (1 hunks)
  • components/airtable_oauth/sources/new-records/new-records.mjs (1 hunks)
✅ Files skipped from review due to trivial changes (24)
  • components/airtable_oauth/actions/update-field/update-field.mjs
  • components/airtable_oauth/actions/create-multiple-records/create-multiple-records.mjs
  • components/airtable_oauth/actions/create-field/create-field.mjs
  • components/airtable_oauth/package.json
  • components/airtable_oauth/actions/search-records/search-records.mjs
  • components/airtable_oauth/actions/update-table/update-table.mjs
  • components/airtable_oauth/actions/update-comment/update-comment.mjs
  • components/airtable_oauth/sources/new-field/new-field.mjs
  • components/airtable_oauth/actions/delete-record/delete-record.mjs
  • components/airtable_oauth/sources/new-modified-or-deleted-records/new-modified-or-deleted-records.mjs
  • components/airtable_oauth/sources/new-or-modified-records-in-view/new-or-modified-records-in-view.mjs
  • components/airtable_oauth/actions/get-record-or-create/get-record-or-create.mjs
  • components/airtable_oauth/actions/create-single-record/create-single-record.mjs
  • components/airtable_oauth/actions/update-record/update-record.mjs
  • components/airtable_oauth/sources/new-modified-or-deleted-records-instant/new-modified-or-deleted-records-instant.mjs
  • components/airtable_oauth/sources/new-records/new-records.mjs
  • components/airtable_oauth/actions/create-table/create-table.mjs
  • components/airtable_oauth/sources/new-or-modified-records/new-or-modified-records.mjs
  • components/airtable_oauth/sources/new-records-in-view/new-records-in-view.mjs
  • components/airtable_oauth/sources/new-or-modified-field/new-or-modified-field.mjs
  • components/airtable_oauth/actions/create-or-update-record/create-or-update-record.mjs
  • components/airtable_oauth/actions/list-records-in-view/list-records-in-view.mjs
  • components/airtable_oauth/actions/list-records/list-records.mjs
  • components/airtable_oauth/actions/create-comment/create-comment.mjs

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

vercel bot commented Apr 22, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
pipedream-docs ⬜️ Ignored (Inspect) Apr 23, 2025 10:16pm
pipedream-docs-redirect-do-not-edit ⬜️ Ignored (Inspect) Apr 23, 2025 10:16pm

@adolfo-pd adolfo-pd added the User submitted Submitted by a user label Apr 22, 2025
@pipedream-component-development
Copy link
Collaborator

Thank you so much for submitting this! We've added it to our backlog to review, and our team has been notified.

@pipedream-component-development
Copy link
Collaborator

Thanks for submitting this PR! When we review PRs, we follow the Pipedream component guidelines. If you're not familiar, here's a quick checklist:

Copy link
Collaborator

@jcortes jcortes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @SokolovskyiK I've just added a minor request change on the component version. Also keep in mind that we need to increase the version in components/airtable_oauth/package.json to 0.4.5

Also because you've touched a common file you need to increment following ones as well:

# MacOS

sed -i '' 's/0.0.10/0.0.11/' components/airtable_oauth/actions/create-comment/create-comment.mjs && sed -i '' 's/0.1.2/0.1.3/' components/airtable_oauth/actions/create-field/create-field.mjs && sed -i '' 's/0.0.10/0.0.11/' components/airtable_oauth/actions/create-multiple-records/create-multiple-records.mjs && sed -i '' 's/0.1.2/0.1.3/' components/airtable_oauth/actions/create-or-update-record/create-or-update-record.mjs && sed -i '' 's/0.0.11/0.0.12/' components/airtable_oauth/actions/create-single-record/create-single-record.mjs && sed -i '' 's/0.0.10/0.0.11/' components/airtable_oauth/actions/create-table/create-table.mjs && sed -i '' 's/0.0.10/0.0.11/' components/airtable_oauth/actions/delete-record/delete-record.mjs && sed -i '' 's/0.0.12/0.0.13/' components/airtable_oauth/actions/get-record-or-create/get-record-or-create.mjs && sed -i '' 's/0.0.10/0.0.11/' components/airtable_oauth/actions/list-records/list-records.mjs && sed -i '' 's/0.0.10/0.0.11/' components/airtable_oauth/actions/list-records-in-view/list-records-in-view.mjs && sed -i '' 's/0.0.12/0.0.13/' components/airtable_oauth/actions/search-records/search-records.mjs && sed -i '' 's/0.0.10/0.0.11/' components/airtable_oauth/actions/update-comment/update-comment.mjs && sed -i '' 's/0.0.10/0.0.11/' components/airtable_oauth/actions/update-field/update-field.mjs && sed -i '' 's/0.0.11/0.0.12/' components/airtable_oauth/actions/update-record/update-record.mjs && sed -i '' 's/0.0.10/0.0.11/' components/airtable_oauth/actions/update-table/update-table.mjs && sed -i '' 's/1.0.2/1.0.3/' components/airtable_oauth/sources/new-field/new-field.mjs && sed -i '' 's/0.0.11/0.0.12/' components/airtable_oauth/sources/new-modified-or-deleted-records/new-modified-or-deleted-records.mjs && sed -i '' 's/0.1.2/0.1.3/' components/airtable_oauth/sources/new-modified-or-deleted-records-instant/new-modified-or-deleted-records-instant.mjs && sed -i '' 's/1.0.2/1.0.3/' components/airtable_oauth/sources/new-or-modified-field/new-or-modified-field.mjs && sed -i '' 's/1.0.2/1.0.3/' components/airtable_oauth/sources/new-or-modified-records/new-or-modified-records.mjs && sed -i '' 's/0.0.12/0.0.13/' components/airtable_oauth/sources/new-or-modified-records-in-view/new-or-modified-records-in-view.mjs && sed -i '' 's/1.0.2/1.0.3/' components/airtable_oauth/sources/new-records/new-records.mjs && sed -i '' 's/0.0.11/0.0.12/' components/airtable_oauth/sources/new-records-in-view/new-records-in-view.mjs && sed -i '' 's/0.1.2/0.1.3/' components/airtable_oauth/actions/create-or-update-record/create-or-update-record.mjs && sed -i '' 's/0.0.11/0.0.12/' components/airtable_oauth/actions/create-single-record/create-single-record.mjs && sed -i '' 's/0.0.12/0.0.13/' components/airtable_oauth/actions/get-record-or-create/get-record-or-create.mjs && sed -i '' 's/0.0.11/0.0.12/' components/airtable_oauth/actions/update-record/update-record.mjs

Let me know if you can do that otherwise I can do it for you thanks!

@SokolovskyiK
Copy link
Contributor Author

Hi @SokolovskyiK I've just added a minor request change on the component version. Also keep in mind that we need to increase the version in components/airtable_oauth/package.json to 0.4.5

Also because you've touched a common file you need to increment following ones as well:

# MacOS

sed -i '' 's/0.0.10/0.0.11/' components/airtable_oauth/actions/create-comment/create-comment.mjs && sed -i '' 's/0.1.2/0.1.3/' components/airtable_oauth/actions/create-field/create-field.mjs && sed -i '' 's/0.0.10/0.0.11/' components/airtable_oauth/actions/create-multiple-records/create-multiple-records.mjs && sed -i '' 's/0.1.2/0.1.3/' components/airtable_oauth/actions/create-or-update-record/create-or-update-record.mjs && sed -i '' 's/0.0.11/0.0.12/' components/airtable_oauth/actions/create-single-record/create-single-record.mjs && sed -i '' 's/0.0.10/0.0.11/' components/airtable_oauth/actions/create-table/create-table.mjs && sed -i '' 's/0.0.10/0.0.11/' components/airtable_oauth/actions/delete-record/delete-record.mjs && sed -i '' 's/0.0.12/0.0.13/' components/airtable_oauth/actions/get-record-or-create/get-record-or-create.mjs && sed -i '' 's/0.0.10/0.0.11/' components/airtable_oauth/actions/list-records/list-records.mjs && sed -i '' 's/0.0.10/0.0.11/' components/airtable_oauth/actions/list-records-in-view/list-records-in-view.mjs && sed -i '' 's/0.0.12/0.0.13/' components/airtable_oauth/actions/search-records/search-records.mjs && sed -i '' 's/0.0.10/0.0.11/' components/airtable_oauth/actions/update-comment/update-comment.mjs && sed -i '' 's/0.0.10/0.0.11/' components/airtable_oauth/actions/update-field/update-field.mjs && sed -i '' 's/0.0.11/0.0.12/' components/airtable_oauth/actions/update-record/update-record.mjs && sed -i '' 's/0.0.10/0.0.11/' components/airtable_oauth/actions/update-table/update-table.mjs && sed -i '' 's/1.0.2/1.0.3/' components/airtable_oauth/sources/new-field/new-field.mjs && sed -i '' 's/0.0.11/0.0.12/' components/airtable_oauth/sources/new-modified-or-deleted-records/new-modified-or-deleted-records.mjs && sed -i '' 's/0.1.2/0.1.3/' components/airtable_oauth/sources/new-modified-or-deleted-records-instant/new-modified-or-deleted-records-instant.mjs && sed -i '' 's/1.0.2/1.0.3/' components/airtable_oauth/sources/new-or-modified-field/new-or-modified-field.mjs && sed -i '' 's/1.0.2/1.0.3/' components/airtable_oauth/sources/new-or-modified-records/new-or-modified-records.mjs && sed -i '' 's/0.0.12/0.0.13/' components/airtable_oauth/sources/new-or-modified-records-in-view/new-or-modified-records-in-view.mjs && sed -i '' 's/1.0.2/1.0.3/' components/airtable_oauth/sources/new-records/new-records.mjs && sed -i '' 's/0.0.11/0.0.12/' components/airtable_oauth/sources/new-records-in-view/new-records-in-view.mjs && sed -i '' 's/0.1.2/0.1.3/' components/airtable_oauth/actions/create-or-update-record/create-or-update-record.mjs && sed -i '' 's/0.0.11/0.0.12/' components/airtable_oauth/actions/create-single-record/create-single-record.mjs && sed -i '' 's/0.0.12/0.0.13/' components/airtable_oauth/actions/get-record-or-create/get-record-or-create.mjs && sed -i '' 's/0.0.11/0.0.12/' components/airtable_oauth/actions/update-record/update-record.mjs

Let me know if you can do that otherwise I can do it for you thanks!

@jcortes Hi. Sure let me do this.

@SokolovskyiK
Copy link
Contributor Author

@jcortes Done! Hopefully I didn’t mess anything up =) Let me know if anything else is needed — happy to adjust.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
User submitted Submitted by a user
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] returnFieldsByFieldId prop not used in airtable_oauth-get-record-or-create
4 participants