Skip to content
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

414 error when using long filterByFormula with single quotes #392

Open
DiscretePython opened this issue Nov 28, 2023 · 0 comments
Open

414 error when using long filterByFormula with single quotes #392

DiscretePython opened this issue Nov 28, 2023 · 0 comments

Comments

@DiscretePython
Copy link

Runtime: NodeJS 18
Library Version: 0.12.2
Workaround: Use double quotes for strings in filterByFormula

I have a filterByFormula that is 13283 characters long when unencoded. It's a long OR(...) function with hundreds of RECORD_ID()='recXXXXXXXXX' comparisons. When I attempt to run select and pass this filter formula I am getting the following:

AirtableError { error: 'UNEXPECTED_ERROR', message: 'An unexpected error occurred', statusCode: 414 }

After some digging I found that the issue is being caused by a discrepancy in the URL encoding of the single quotes around the record ids. Here the function encodeURIComponent encodes the URL without encoding single quotes resulting in a length of 15010. However, when node-fetch makes the API call, it internally encodes the URL with the single quotes encoded resulting in a longer URL length above the 16k char limit, hence the 414 error.

Making the following change resolves the issue for me but there may be a better solution:

parts.push(`${encodeURIComponent(key)}=${encodeURIComponent(value)}`);
to
parts.push(`${encodeURIComponent(key)}=${encodeURIComponent(value).replace(/'/g, "%27")}`);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant