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(wordpress): stop retrying a TLS hostname/certificate mismatch (#80281)

Tom Owersbed0f2650f9e
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/wordpress/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/wordpress/source.py
index 68b8521e81e0..ebbb4b6fc982 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/wordpress/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/wordpress/source.py
@@ -106,6 +106,12 @@ To sync private content or authenticate, create an [Application Password](https:
# a security or caching plugin) can't be turned into rows by retrying. Matches the stable
# prefix RESTClientNonRetryableError uses, not the variable URL that follows.
"Non-JSON response from": "The WordPress site returned a non-JSON response (for example an HTML error, login, or maintenance page) instead of data. Confirm the REST API is enabled and reachable at this URL and isn't blocked by a security or caching plugin, then try again.",
+ # The site's TLS certificate doesn't cover its own hostname — common on shared hosting
+ # platforms whose default certificate doesn't include the customer's custom domain. The
+ # cert is wrong every time, not just this request, so retrying can't help. Match the
+ # exception class name that `ssl_match_hostname.match_hostname` raises, not the hostname
+ # or cert names that follow it in the message.
+ "CertificateError": "The WordPress site's TLS certificate doesn't match its domain. This is often caused by a hosting platform's default certificate not covering a custom domain. Ask your hosting provider to install a certificate for this domain, then try again.",
}
def get_canonical_descriptions(self) -> CanonicalDescriptions:
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/wordpress/tests/test_wordpress_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/wordpress/tests/test_wordpress_source.py
index 28a37fe22b5c..41eb4058d92b 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/wordpress/tests/test_wordpress_source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/wordpress/tests/test_wordpress_source.py
@@ -52,7 +52,8 @@ class TestWordpressSource:
assert pass_field.secret is True
@pytest.mark.parametrize(
- "expected_key", ["401 Client Error", "403 Client Error", "404 Client Error", "Non-JSON response from"]
+ "expected_key",
+ ["401 Client Error", "403 Client Error", "404 Client Error", "Non-JSON response from", "CertificateError"],
)
def test_non_retryable_errors(self, expected_key):
assert expected_key in self.source.get_non_retryable_errors()
@@ -65,6 +66,19 @@ class TestWordpressSource:
matches = [friendly for key, friendly in errors.items() if key in raised]
assert matches and matches[0] is not None
+ def test_certificate_error_message_matches_non_retryable_error(self):
+ # requests wraps a hostname/cert mismatch as an SSLError whose message embeds the
+ # underlying CertificateError; the classifier matches on that class name, so the variable
+ # hostname and cert names around it must not stop it being recognised as non-retryable.
+ errors = self.source.get_non_retryable_errors()
+ raised = (
+ "HTTPSConnectionPool(host='example.com', port=443): Max retries exceeded with url: "
+ "/wp-json/wp/v2/categories (Caused by SSLError(CertificateError(\"hostname 'example.com' "
+ "doesn't match either of '*.example-host.test', 'example-host.test'\")))"
+ )
+ matches = [friendly for key, friendly in errors.items() if key in raised]
+ assert matches and matches[0] is not None
+
def test_get_schemas_returns_all_endpoints(self):
schemas = self.source.get_schemas(self.config, self.team_id)
assert {s.name for s in schemas} == set(ENDPOINTS)