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(vapi): stop retrying the v2 phone-number 400 error (#83416)

Tom Owers01c55b75aa0e
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/vapi/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/vapi/source.py
index 216662327fcf..438817112dd6 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/vapi/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/vapi/source.py
@@ -88,6 +88,12 @@ You can find your private API key in the [Vapi dashboard](https://dashboard.vapi
return {
"401 Client Error: Unauthorized for url: https://api.vapi.ai": "Your Vapi API key is invalid or has been revoked. Create a new private API key in the Vapi dashboard, then reconnect.",
"403 Client Error: Forbidden for url: https://api.vapi.ai": "Your Vapi API key does not have permission to read this data. Check the key's permissions in the Vapi dashboard, then reconnect.",
+ # Vapi's v2 phone-number list endpoint rejects our request with a 400 for some
+ # accounts even though the query (limit/page/sortOrder/sortBy=createdAt) matches
+ # Vapi's own published spec byte for byte — every retry replays the identical,
+ # spec-compliant request and gets the same 400 back. Match the path, not the
+ # per-request query string, so this stays scoped to this one known-bad endpoint.
+ "400 Client Error: Bad Request for url: https://api.vapi.ai/v2/phone-number": "Vapi rejected the request to list phone numbers on API v2 for this account. This looks like an issue on Vapi's side rather than your credentials — contact Vapi support, or disable the phone_numbers table if you don't need it.",
}
def get_schemas(
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/vapi/tests/test_vapi_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/vapi/tests/test_vapi_source.py
index b312df66881b..dae0bf74d380 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/vapi/tests/test_vapi_source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/vapi/tests/test_vapi_source.py
@@ -53,6 +53,7 @@ class TestVapiSource:
[
"401 Client Error: Unauthorized for url: https://api.vapi.ai/call?limit=100",
"403 Client Error: Forbidden for url: https://api.vapi.ai/assistant?limit=100",
+ "400 Client Error: Bad Request for url: https://api.vapi.ai/v2/phone-number?limit=100&page=1&sortOrder=ASC&sortBy=createdAt",
]
)
def test_non_retryable_errors_match_auth_failures(self, observed_error):
@@ -64,6 +65,9 @@ class TestVapiSource:
"429 Client Error: Too Many Requests for url: https://api.vapi.ai/call",
"500 Server Error: Internal Server Error for url: https://api.vapi.ai/call",
"HTTPSConnectionPool(host='api.vapi.ai', port=443): Read timed out.",
+ # A 400 on a different endpoint must stay retryable — only the known-bad v2
+ # phone-number path is non-retryable, not every 400 from api.vapi.ai.
+ "400 Client Error: Bad Request for url: https://api.vapi.ai/call?limit=100",
]
)
def test_non_retryable_errors_do_not_match_transient(self, other_error):