Skip to content

: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.

fix(cosmosdb): recognize firewall-blocked 403s as non-retryable (#130497)

Tom Owersbc81416e50fd
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/tests/test_source_error_contract.py b/products/warehouse_sources/backend/temporal/data_imports/sources/tests/test_source_error_contract.py
index b89e8c58c77d..f6afc3ecb296 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/tests/test_source_error_contract.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/tests/test_source_error_contract.py
@@ -470,6 +470,14 @@ def test_allowlists_name_only_extracting_sources(allowlist: dict[str, Any]) -> N
"Appdynamics",
"AppDynamics OAuth token request failed. Check your API client name, client secret, and account name.",
),
+ # A firewall-blocked request gets a custom reason phrase from Azure instead of "Forbidden",
+ # matched on the stable wording rather than the appended IP address and URL.
+ (
+ "CosmosDB",
+ "403 Client Error: Request originated from IP 10.0.0.1 through public internet. This is "
+ "blocked by your Cosmos DB account firewall settings. More info: "
+ "https://aka.ms/cosmosdb-tsg-forbidden for url: https://unit-test.documents.azure.com/dbs/shop/colls",
+ ),
# DataForSEO doesn't reliably send the standard reason phrase ("Unauthorized", "Payment
# Required") on every response (observed in production: "402 Client Error: Unknown for
# url: ...").
diff --git a/products/warehouse_sources/sources/cosmosdb/source.py b/products/warehouse_sources/sources/cosmosdb/source.py
index ee0a946a5232..da71e68558ab 100644
--- a/products/warehouse_sources/sources/cosmosdb/source.py
+++ b/products/warehouse_sources/sources/cosmosdb/source.py
@@ -112,6 +112,9 @@ Enter the account endpoint (`https://<account>.documents.azure.com`), a read-onl
return {
"401 Client Error: Unauthorized for url:": "Azure Cosmos DB rejected the account key. Copy a current key from the account's Keys page and reconnect.",
"403 Client Error: Forbidden for url:": FORBIDDEN_MESSAGE,
+ # A firewall-blocked request gets a custom reason phrase instead of "Forbidden", so it
+ # needs its own key. Matched on Azure's stable wording, not the appended IP or URL.
+ "blocked by your Cosmos DB account firewall settings": FORBIDDEN_MESSAGE,
"404 Client Error:": "The database or container no longer exists in this Cosmos DB account. Check the source settings and the table list.",
"Azure Cosmos DB account key is not valid base64": "The account key is not valid. Copy the primary or secondary key from the account's Keys page and reconnect.",
}