Skip to content

Commit 0f3ab40

Browse files
authored
🐛 [source-facebook-marketing] Should not run migration if the legacy field account_id is not present (#37367)
1 parent 2944b19 commit 0f3ab40

File tree

6 files changed

+26
-3
lines changed

6 files changed

+26
-3
lines changed

airbyte-integrations/connectors/source-facebook-marketing/metadata.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ data:
1010
connectorSubtype: api
1111
connectorType: source
1212
definitionId: e7778cfc-e97c-4458-9ecb-b4f2bba8946c
13-
dockerImageTag: 2.1.3
13+
dockerImageTag: 2.1.4
1414
dockerRepository: airbyte/source-facebook-marketing
1515
documentationUrl: https://docs.airbyte.com/integrations/sources/facebook-marketing
1616
githubIssueLabel: source-facebook-marketing

airbyte-integrations/connectors/source-facebook-marketing/pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ requires = [ "poetry-core>=1.0.0",]
33
build-backend = "poetry.core.masonry.api"
44

55
[tool.poetry]
6-
version = "2.1.3"
6+
version = "2.1.4"
77
name = "source-facebook-marketing"
88
description = "Source implementation for Facebook Marketing."
99
authors = [ "Airbyte <[email protected]>",]

airbyte-integrations/connectors/source-facebook-marketing/source_facebook_marketing/config_migrations.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def should_migrate(cls, config: Mapping[str, Any]) -> bool:
3838
> False, otherwise.
3939
> Raises the Exception if the structure could not be migrated.
4040
"""
41-
return False if config.get(cls.migrate_to_key) else True
41+
return cls.migrate_from_key in config and cls.migrate_to_key not in config
4242

4343
@classmethod
4444
def transform(cls, config: Mapping[str, Any]) -> Mapping[str, Any]:

airbyte-integrations/connectors/source-facebook-marketing/unit_tests/test_config_migrations.py

+9
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class TestMigrateAccountIdToArray:
2727
TEST_CONFIG_PATH = "unit_tests/test_migrations/account_id_to_array/test_old_config.json"
2828
NEW_TEST_CONFIG_PATH = "unit_tests/test_migrations/account_id_to_array/test_new_config.json"
2929
UPGRADED_TEST_CONFIG_PATH = "unit_tests/test_migrations/account_id_to_array/test_upgraded_config.json"
30+
NEW_CONFIG_WITHOUT_ACCOUNT_ID = "unit_tests/test_migrations/account_id_to_array/test_new_config_without_account_id.json"
3031

3132
@staticmethod
3233
def revert_migration(config_path: str = TEST_CONFIG_PATH) -> None:
@@ -86,6 +87,14 @@ def test_should_not_migrate_upgraded_config(self):
8687
migration_instance = MigrateAccountIdToArray()
8788
assert not migration_instance.should_migrate(new_config)
8889

90+
def test_should_not_migrate_config_without_account_id(self):
91+
# OC Issue: https://github.com/airbytehq/oncall/issues/4131
92+
# Newly created sources will not have the deprecated `account_id` field, and we should not attempt to migrate
93+
# because it is already in the new `account_ids` format
94+
new_config = load_config(self.NEW_CONFIG_WITHOUT_ACCOUNT_ID)
95+
migration_instance = MigrateAccountIdToArray()
96+
assert not migration_instance.should_migrate(new_config)
97+
8998

9099
class TestMigrateIncludeDeletedToStatusFilters:
91100
OLD_TEST1_CONFIG_PATH = "unit_tests/test_migrations/include_deleted_to_status_filters/include_deleted_false/test_old_config.json"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"start_date": "2021-02-08T00:00:00Z",
3+
"end_date": "2021-02-15T00:00:00Z",
4+
"custom_insights": [
5+
{
6+
"name": "custom_insight_stream",
7+
"fields": ["account_name", "clicks", "cpc", "account_id", "ad_id"],
8+
"breakdowns": ["gender"],
9+
"action_breakdowns": []
10+
}
11+
],
12+
"access_token": "access_token"
13+
}

docs/integrations/sources/facebook-marketing.md

+1
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ The Facebook Marketing connector uses the `lookback_window` parameter to repeate
200200

201201
| Version | Date | Pull Request | Subject |
202202
|:--------|:-----------|:---------------------------------------------------------|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
203+
| 2.1.4 | 2024-04-16 | [37367](https://github.com/airbytehq/airbyte/pull/37367) | Skip config migration when the legacy account_id field does not exist |
203204
| 2.1.3 | 2024-04-16 | [37320](https://github.com/airbytehq/airbyte/pull/37320) | Add retry for transient error |
204205
| 2.1.2 | 2024-03-29 | [36689](https://github.com/airbytehq/airbyte/pull/36689) | Fix key error `account_id` for custom reports. |
205206
| 2.1.1 | 2024-03-18 | [36025](https://github.com/airbytehq/airbyte/pull/36025) | Fix start_date selection behaviour |

0 commit comments

Comments
 (0)