: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(sonarqube): stop retrying syncs pointed at a SonarQube Cloud host (#98590)
Tom Owers874c15d6bf77
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/sonarqube/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/sonarqube/source.pyindex 2f4c5bccb756..6ec3dd90de4a 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/sonarqube/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/sonarqube/source.py@@ -87,6 +87,14 @@ Enter your server URL (e.g. `https://sonarqube.yourcompany.com`) and a user tokedef get_non_retryable_errors(self) -> dict[str, str | None]:return {+ # This source only talks to a self-hosted SonarQube Server. If the configured host is+ # actually SonarQube Cloud, every request fails identically: SonarQube Cloud's API+ # requires an `organization` parameter this source never sends. Match the stable,+ # vendor-owned hostnames (not anything the customer typed) rather than the endpoint path.+ # The trailing slash anchors the match to the exact host, so a self-hosted domain that+ # merely contains these strings (e.g. `sonarcloud.io.example.com`) doesn't match.+ "for url: https://sonarcloud.io/": "This server URL points to SonarQube Cloud, which this source doesn't support. Remove this source and add it again using the SonarQube Cloud source instead.",+ "for url: https://sonarqube.us/": "This server URL points to SonarQube Cloud, which this source doesn't support. Remove this source and add it again using the SonarQube Cloud source instead.",# 401/403 surface as a requests HTTPError when `_fetch_page` calls `raise_for_status()`.# Retrying can never fix a credential/permission problem, so fail the sync. Match the# stable status text, not the per-request URL.diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/sonarqube/tests/test_sonarqube_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/sonarqube/tests/test_sonarqube_source.pyindex 169a2b0081d4..d9355c832aaa 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/sonarqube/tests/test_sonarqube_source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/sonarqube/tests/test_sonarqube_source.py@@ -49,12 +49,31 @@ class TestSonarqubeSource:"429 Client Error: Too Many Requests for url: https://sonar.example.com/api/issues/search","500 Server Error: Internal Server Error for url: https://sonar.example.com/api/issues/search","HTTPSConnectionPool(host='sonar.example.com', port=443): Read timed out.",+ # A self-hosted domain that merely contains the SonarQube Cloud hostname as a substring+ # must not be caught by the host-misconfiguration match below.+ "400 Client Error: Bad Request for url: https://sonarcloud.io.example.com/api/issues/search",+ "400 Client Error: Bad Request for url: https://sonarqube.us-backup.mycompany.com/api/issues/search",],)def test_non_retryable_errors_do_not_match_transient(self, other_error):non_retryable_errors = self.source.get_non_retryable_errors()assert not any(key in other_error for key in non_retryable_errors)+ @pytest.mark.parametrize(+ "observed_error",+ [+ "400 Client Error: for url: https://sonarcloud.io/api/issues/search?s=CREATION_DATE&asc=true&p=1&ps=500",+ "400 Client Error: Bad Request for url: https://sonarqube.us/api/issues/search?p=1&ps=500",+ ],+ )+ def test_non_retryable_errors_match_sonarcloud_host_misconfiguration(self, observed_error):+ # This source only supports self-hosted SonarQube Server; a request landing on a SonarQube+ # Cloud host means the configured server URL points at the hosted product instead, which+ # always fails identically (SonarQube Cloud's API requires an `organization` parameter this+ # source never sends).+ non_retryable_errors = self.source.get_non_retryable_errors()+ assert any(key in observed_error for key in non_retryable_errors)+def test_get_schemas_match_endpoints_with_correct_sync_modes(self):schemas = {schema.name: schema for schema in self.source.get_schemas(self.config, self.team_id)}