:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(instagram): say what a rejected account ID should look like (#96371)
Tom Owers34e27b633be8
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/instagram/instagram.py b/products/warehouse_sources/backend/temporal/data_imports/sources/instagram/instagram.pyindex ac7d14ee87a4..d6bb37317737 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/instagram/instagram.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/instagram/instagram.py@@ -35,6 +35,15 @@ MAX_RETRY_ATTEMPTS = 5# risks retargeting the request at a different object or injecting path/query segments._NUMERIC_ACCOUNT_ID = re.compile(r"^[0-9]+$")+# The account field accepts an ID typed by hand, which is the only way to reach an account a+# Business portfolio owns (see `list_professional_accounts`). Someone typing there usually reaches+# for the username, so name the value the Graph API needs instead of sending them back to a list+# their account is missing from.+_ACCOUNT_ID_NOT_NUMERIC_ERROR = (+ "Instagram professional accounts use a numeric ID, not a username. Pick the account from the "+ "list, or enter its numeric ID from your Meta business settings."+)+# The media edge tops out at 10K posts; at PAGE_SIZE per page that is 100 pages. The cap# is a runaway guard for a paginator that never signals the end, not a real limit.MAX_PAGES_PER_STREAM = 500@@ -666,7 +675,7 @@ def validate_credentials(# The account ID is spliced straight into the Graph API path, so anything but the plain# numeric node ID could select a different object or inject extra path/query segments.if not _NUMERIC_ACCOUNT_ID.match(account_id):- return False, "That is not a valid Instagram account. Pick the account again from the list."+ return False, _ACCOUNT_ID_NOT_NUMERIC_ERRORclient = InstagramClient(access_token=access_token, api_version=api_version, logger=logger)diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/instagram/tests/test_instagram.py b/products/warehouse_sources/backend/temporal/data_imports/sources/instagram/tests/test_instagram.pyindex 2d7a2458ee25..f7e817d569f6 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/instagram/tests/test_instagram.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/instagram/tests/test_instagram.py@@ -10,6 +10,7 @@ import structlogfrom products.warehouse_sources.backend.temporal.data_imports.sources.common.resumable import ResumableSourceManagerfrom products.warehouse_sources.backend.temporal.data_imports.sources.instagram.instagram import (+ _ACCOUNT_ID_NOT_NUMERIC_ERROR,AUTH_ERROR_PREFIX,MAX_REQUESTS_PER_SYNC,MAX_RETRY_ATTEMPTS,@@ -851,7 +852,7 @@ class TestValidateCredentials:is_valid, message = validate_credentials("tok", "v23.0", LOGGER, instagram_account_id=account_id)assert is_valid is False- assert message is not None and "not a valid Instagram account" in message+ assert message == _ACCOUNT_ID_NOT_NUMERIC_ERRORassert session.requested_urls == []