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(new_relic): retry NerdGraph's generic NRDB error instead of failing the sync (#88859)

Tom Owers0b766bb17c1d
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/new_relic/new_relic.py b/products/warehouse_sources/backend/temporal/data_imports/sources/new_relic/new_relic.py
index 953c15e5c800..487ee6d0d75d 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/new_relic/new_relic.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/new_relic/new_relic.py
@@ -199,9 +199,18 @@ def _execute_graphql(
# "An error occurred resolving this field" is NerdGraph's generic resolver-failure
# message; it's known to fire intermittently on otherwise-valid queries and clear on
# retry (e.g. the New Relic Terraform provider retries the same message).
+ # "There was an NRDB error" is NRDB's own generic wrapper for a backend-side query
+ # execution failure (heavy load, an internal engine fault) with no further detail;
+ # New Relic's own docs describe it as clearing on retry, same as the messages above.
if any(
term in messages.lower()
- for term in ("timeout", "deadline", "too many requests", "an error occurred resolving this field")
+ for term in (
+ "timeout",
+ "deadline",
+ "too many requests",
+ "an error occurred resolving this field",
+ "there was an nrdb error",
+ )
):
raise NewRelicRetryableError(f"New Relic GraphQL error (retryable): {messages}")
raise NewRelicGraphQLError(f"New Relic GraphQL error: {messages}")
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/new_relic/tests/test_new_relic.py b/products/warehouse_sources/backend/temporal/data_imports/sources/new_relic/tests/test_new_relic.py
index 80b87b34b7f4..fc2d73f9fce1 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/new_relic/tests/test_new_relic.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/new_relic/tests/test_new_relic.py
@@ -144,6 +144,7 @@ class TestExecuteGraphql:
("deadline", "Deadline exceeded"),
("throttled", "Too many requests"),
("resolver_failure", "An error occurred resolving this field"),
+ ("nrdb_error", "There was an NRDB error"),
]
)
def test_transient_graphql_errors_are_retryable(self, _name: str, message: str) -> None: