Error when upgrading Facebook Marketing Source and Postgres Destination


Encountering a KeyError ‘account_id’ error after upgrading Facebook Marketing Source and Postgres Destination. New sources, destinations, and connectors work fine, but older ones throw this error.


Hey team,

I recently upgraded my Facebook Marketing Source from v1.4.2 to v2.0.0 and Postgres Destination from v0.6.3 to v2.0.4. However, after the upgrade, I’m encountering the following error:

2024-03-09 14:25:26 source > Encountered an exception while reading stream customads_age_gender_action_type
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/airbyte_cdk/sources/", line 126, in read
    yield from self._read_stream(
  File "/usr/local/lib/python3.9/site-packages/airbyte_cdk/sources/", line 203, in _read_stream
    for record in record_iterator:
  File "/usr/local/lib/python3.9/site-packages/airbyte_cdk/sources/", line 239, in _read_incremental
    for record_data_or_message in stream_instance.read_incremental(
  File "/usr/local/lib/python3.9/site-packages/airbyte_cdk/sources/streams/", line 162, in read_incremental
    stream_state = self.get_updated_state(stream_state, record_data)
  File "/airbyte/integration_code/source_facebook_marketing/streams/", line 249, in get_updated_state
    account_id = latest_record["account_id"]
KeyError: 'account_id'

I’ve attached the complete traceback for reference.
Additionally, here’s the schema for my custom insight:

            "name": "ads_age_gender_action_type",
            "level": "ad",
            "fields": [
                "   ",
            "breakdowns": ["age", "gender"],
            "start_date": start_date,
            "time_increment": 1,
            "action_breakdowns": ["action_type"],
            "action_report_time": "mixed",
            "insights_lookback_window": 28,

Interestingly, creating new sources, destinations, and connectors for different Facebook Account works without any issue. It’s only when upgrading the older ones that this error occurs.

Could anyone please assist me in resolving this issue?

This topic has been created from a Slack thread to give it more visibility.
It will be on Read-Only mode here. Click here if you want to access the original thread.

Join the conversation on Slack

["facebook-marketing-source", "postgres-destination", "upgrade-error", "keyerror", "account-id"]