Baserow -> n8n -> Google Calendar error

Please fill in the questionnaire below.

How have you self-hosted Baserow.

Official docker container with separate postgres container

Which version of Baserow are you using.

1.30.1

Describe the problem

EDIT! TLDR from my updates. I worked out that the issue is the webhook is sending the row data to n8n before the formula field is updated.

IE. I have 3 fields:

  • “start date”
  • “duration”
  • “end date” - which is calculated from the “start date” and “duration”

When I update the “start date” my webhook sends the information to n8n before the “end date” is calculated, resulting in the incorrect data being sent. In order to get the correct data sent, I have to make another update (any one will do) to re-trigger the webhook and send the correct “end date” to n8n. this seems to maybe be a timing issue? I’m nt sure how to build in a delay or something before the webhook is triggered

My full journey to come to this conclusion is below for the bored :wink:

It’s another strange one - and probably complex due to the integration of Baserow, n8n and Google Calendar API. However, due to the nature of the issue, I suspect the problem is originating from Baserow and not the other 2 services.

I have Baserow and n8n. I have 2 webhooks from baserow to n8n:

  1. New-booking-n8n
  • Triggered when Rows are created
  • POST to my n8n workflow called “Kapt-New-Booking”
  • This one basically uses n8n to create a calendar entry in Google Calendar when a new booking comes into my Baserow app. It then writes the Google Cal Id into the a field called “Google-Cal_ID” in the row in BaseRow so it an be used to update the calendar entry if needed later (see next one). It works perfectly fine with no issues.
  1. Update-booking-n8n
  • Triggered when rows are updated
  • POST to my n8n workflow called “Kapt-Update_booking”
  • This one updates the Google calendar event if a field in the row changes. It uses the “Google-Cal_ID” to know which calendar entry to update.

The strange thing about the 2nd one is it work for most fields. For example, my row has the following fields that can be updated:

  • First Name
  • Last Name
  • Email
  • Phone
  • Package
  • Location
  • Date
  • Time
    plus a few others.

If I change any of these fields, the webhook and n8n workflow work fine and the Google Calendar entry is updated - except the “Date”. If I change the date only, the workflow fails and the Google Calendar entry is not updated. However… if I change a different field as well - or I go back in and change a different field (and trigger the webhook again) then the date is updated in Google Calendar.

So I know that everything is mapped correctly and that the webhook is working. But I can’t work out why it doesn’t work if I just change the date.

For example. If I change only date on a row, I’ll see that the workflow failed in n8n and the Google Calendar entry will not update with the new date. Looking at the n8n logs, the part that fails is the “update event” to the Google Cal API, and the error message is: “The specified time range is empty.” However, my time range looks fine:

  • Start: 2025-01-19T02:00:00+00:00
  • End: 2025-01-18T02:00:00+00:00

To compare it. I’ll trigger the webhook again with the same row. But this time I’ll change the “Location”. Since I changed the date on the previous example, it will update correctly this time. However, the start and end times are exactly the same:

  • Start: 2025-01-19T02:00:00+00:00
  • End: 2025-01-19T03:00:00+00:00

The only other thing that changed was the location. This is the same no matter what other field I change. Even if I just change the description and the date, it works fine. It will only throw an error if I change only thedate.

I’m at a loss as to how to troubleshoot this as it seems that the data is the same. Have you guys seen anything like this?

Ha! As is often the case with these things, the act of writing down the issue and copying examples etc has helped me to work out where the source of the issue is!

So my “End Time” is actually a calculation of the “Start Time” and the “Duration”. When I looked at the example I wrote earlier and then tested on further examples, I worked out that the Google Calendar API error is occurring because the “End Time” is actually before the “Start Time”. That seems to be because the webhook is being triggered before the calculation is done.

For example, I’ll change the date from 21/01/25 to 25/01/25. When I make the change in Baserow, I see this in n8n:

Start: 2025-01-25T02:00:00+00:00
End: 2025-01-21T02:30:00+00:00

So Baserow has sent the end date before if calculates a new one. If I update the row again (by changing a different field) and re-trigger the webhook, it sends the correct end date (which was calculated in the previous update):

Start: 2025-01-25T02:00:00+00:00
End: 2025-01-25T02:30:00+00:00

And since the end date is no longer before the start date, Google Calendar doesn’t reject it!

So I guess my new question is, how can I “delay” the webhook until after the calculation is complete so it sends the correct data?

Note - another symptom of this which was making it difficult for me to find a pattern was that if I changed the time or date to before the current time, it would not error. In Google Calendar, the start date would change as it should. However, what I didn’t notice at first was that the end date would still not change. So if my booking was from 12pm with a duration of 1 hour, and I change it to 11am. The end time would remain at 1pm (even though it should change to 12pm). However, since the start time was still before the end time, Google Calendar would accept it.

Then if I then make a different change to the row,m the end tile will update correctly.

Hi @spook,

thanks for taking the time to investigate and report the issue.

I am not able to replicate it trying to trigger updates for a data field calculated from another date field and duration for our rows_updated webhooks.

Could you come up with a specific, simple, reproducible example that will include the SPECIFIC field configuration that you have for all this 3 fields that I could easily follow step by step to arrive to the problem?

Thanks so much for the fast reply! Is it possible that it is related to the number of formula fields and calculations being done every time the row updates? I do have a lot of formula fields so maybe it’s just too many calculations at once?

Rather than try and recreate the issue, maybe I can give you access to my DB? It is currently in development, so there is no sensitive information in it. Can I DM you access or something?

Cheers.

Edit: In the meantime, I’ve found a dodgy work-around. In the form in my application, I have created a button with an “Update Row” event , followed by a “Show Notification” event, followed by another “Update Row” event.

The 1st Update row triggers the webhook with the wrong data (which then causes a fail in n8n trying to update Google Cal), but the 2nd sends the right data (since it was obviously a long enough pause before sending and sends the correct data). This isn’t ideal, but at least it buys time to try and resolve the issue.

Can you think of a way to somehow pause the webhook for a second or so? I was thinking of maybe some kind of formula field that updates a second after and trigger the webhook off that? But I can’t work out if that’s possible…

Yes it is possible that there is something wrong with the formula calculations for complex dependencies between fields as I wasn’t able to reproduce the problem with simple formula field referencing/computing the result just from two other fields in one go (I didn’t have any intermediate formulas etc.).

Feel free to DM us (me) your exported workspace applications and we will take a look. Maybe @davide have some idea why that is happening.

Thank you!

Will do. In the meantime, I’ve thought of a possible work-around. I’m going to create a second webhook that will only activate when the “End Time” changes. I’ll then map that do a seperate workflow in n8n. That way, the 1st webhook will trigger if any other field changes (eg location, package) and the 2nd webhook will only trigger once the end date / time changes. I think that should work, but I’ll confirm and let you know.

Thanks again for such fast and helpful responses.

Hmm. It looks like my bright idea isn’t working. If I choose the to trigger the webhook off my formula field “End time”, it doesn’t seem to trigger. Do webhooks not work on formula fields?

Damn. Looks like webhooks don’t trigger on lookups either! I created a new table called “Bookings-4-webhooks” and set every field as a lookup to the identical field in the original table (Bookings). I thought that way it would lookup all the fields at once. But I can’t trigger a webhook on any of the fields in that table either - I assume because lookups don’t trigger a webhook…

OK. I think I have worked out a rather convoluted work-around.

  1. Webhook sends row to n8n on update
  2. n8n uses row_id to fetch the row using the BaseRow plugin (essentially retrieving the same data that was sent, but this give the formula field time to update)
  3. n8n then updates google cal with the correct times.

Testing now, but this seems to work - even though it’s a bit redundant.

EDIT: Testing works. so this gets around the issue - presumably by introducing a delay between the formula updating and n8n retrieving the data. The downside is there is some redundancy.

@petrs if you are able to replicate with the export I sent, a resolution may be to introduce a tiny delay before the webhook triggers?