Inconsistent data retrieval from Airtable database queries

I’m working with the official Airtable JavaScript SDK in my Node.js project and running into a frustrating issue. When I query records using filterByFormula, the results are unreliable. Sometimes the same query returns the expected record, other times it comes back empty even when I know the data exists.

My workflow checks if a booking already exists before deciding whether to create a new one or update the existing entry. When the query fails to find existing records, I end up with duplicates in my database.

Here’s my lookup function:

findBookingByReference: async (refNumber) => {
  let bookings = await dataBase('Bookings').select({
    view: 'Grid view',
    filterByFormula: `{Reference Number} = "${refNumber}"`,
    maxRecords: 1,
  }).all();

  return (bookings.length > 0) ? bookings[0] : null;
},

And here’s how I use it:

let existingBooking = await findBookingByReference(booking.reference);
if (!existingBooking) {
  addNewBooking(booking);
} else {
  modifyBooking(booking);
}

Has anyone experienced similar reliability issues with Airtable queries? Is there a better approach to ensure consistent results?

Been there. This exact thing bit me on a project last year.

It’s probably race conditions. When you’re running multiple operations quickly, Airtable’s API gets confused about your data’s current state. Their consistency isn’t always immediate.

I fixed it with a small delay and retry logic:

findBookingByReference: async (refNumber, retries = 2) => {
  for (let i = 0; i <= retries; i++) {
    let bookings = await dataBase('Bookings').select({
      view: 'Grid view',
      filterByFormula: `{Reference Number} = "${refNumber}"`,
      maxRecords: 1,
    }).all();
    
    if (bookings.length > 0 || i === retries) {
      return bookings.length > 0 ? bookings[0] : null;
    }
    
    await new Promise(resolve => setTimeout(resolve, 500));
  }
},

Check if your Reference Number field has hidden characters or formatting issues too. I once spent hours debugging only to find trailing spaces in the data.

Make sure you’re not hitting rate limits either. Airtable gets cranky with too many requests too fast.

This usually happens because of how Airtable handles string matching in filterByFormula. I hit the same issue - turns out special characters or encoding differences in reference numbers were causing silent failures. The formula looked right but missed records with tiny character variations.

Try FIND instead of direct equality:

findBookingByReference: async (refNumber) => {
  let bookings = await dataBase('Bookings').select({
    filterByFormula: `FIND("${refNumber}", {Reference Number}) > 0`,
    maxRecords: 1,
  }).all();

  return (bookings.length > 0) ? bookings[0] : null;
},

Also check if your reference numbers have URL encoding or unicode characters that don’t match exactly. I started logging both the search value and actual field values to compare them byte by byte when debugging.

Had this exact issue about six months ago. Turns out Airtable’s view filtering was messing with my query results. When you specify a view in your select operation, you’re basically running two filters at once - the view’s filters plus your filterByFormula. Creates weird inconsistent behavior.

Drop the view parameter completely and just use filterByFormula. My code went from flaky to bulletproof:

findBookingByReference: async (refNumber) => {
  let bookings = await dataBase('Bookings').select({
    filterByFormula: `{Reference Number} = "${refNumber}"`,
    maxRecords: 1,
  }).all();

  return (bookings.length > 0) ? bookings[0] : null;
},

Also check if your Reference Number field is a formula field or linked record - those can be inconsistent with direct string comparisons in filterByFormula.

sounds like airtables eventual consistency acting up. try .firstPage() instead of .all() - works better for single record lookups sometimes. also double check your field names match exactly; the case sensitive thing trips up tons of people with filterByFormula.