fix(gong): treat empty calls window 404 as no data#67264
Conversation
Gong's `/v2/calls` endpoint answers a date window that contains no processed
calls with a 404 ("No calls found corresponding to the provided filters")
instead of an empty 200 response. During incremental syncs this crashes the
whole sync whenever a window has no new calls.
Treat a 404 whose body signals no calls as an empty page so the sync skips the
window and advances, instead of raising HTTPError.
Generated-By: PostHog Code
Task-Id: 6fb8dd8b-adfd-412e-8aae-c46bfc96960e
|
Hey @Gilbert09! 👋 It looks like your git author email on this PR isn't your
You can fix it for this repo with: git config user.email "you@posthog.com"Or set it globally with |
There was a problem hiding this comment.
Pull request overview
Fixes Gong data-warehouse imports aborting on incremental /v2/calls windows that contain no processed calls (Gong returns a documented 404 in this case), by treating that specific 404 as “no data” and continuing the window iterator.
Changes:
- Update
fetch_pageto treat a 404 response whose body indicates “no calls” as an empty page (return{}) instead of raising. - Add a regression test that simulates a two-window
callssync where the first window returns the “no calls” 404 and the second returns data.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| products/warehouse_sources/backend/temporal/data_imports/sources/gong/gong.py | Handles Gong’s “no calls” 404 as an empty page so windowed syncs can continue. |
| products/warehouse_sources/backend/temporal/data_imports/sources/gong/tests/test_gong.py | Adds regression coverage for skipping an empty 404 window and proceeding to the next window. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Reviews (1): Last reviewed commit: "fix(gong): treat empty calls window 404 ..." | Re-trigger Greptile |
Address review feedback: - Gate the 404 "no calls" handling on the date-window endpoint so it can't swallow a genuine 404 from another Gong endpoint that happens to share wording. - Parameterize the test to also cover the branch where an unrelated 404 still raises, not just the empty-window skip. Generated-By: PostHog Code Task-Id: 6fb8dd8b-adfd-412e-8aae-c46bfc96960e
New commits pushed (delta classified non_trivial_delta) — stamphog approval dismissed; re-review running automatically.
There was a problem hiding this comment.
Narrow, well-targeted fix for a Gong API quirk with three-part guard condition (date-window flag + 404 + body contains "no calls"), and parameterized tests covering both the skip and raise paths. Both resolved review comments were addressed. Author owns the area.
Problem
Gong data-warehouse imports were failing with an unhandled
HTTPErrorraised from the source'sfetch_page(error tracking issue):Gong's
/v2/callsendpoint answers a date window that contains no processed calls with a404({"errors": ["No calls found corresponding to the provided filters"]}) rather than an empty200. This is documented, expected behaviour — the endpoint only returns completed calls, so a range with none returns 404.The
callsschema is synced by iterating bounded date windows. On incremental syncs the windows are short, so any window with no new calls hit the 404 and aborted the entire sync. The credentials are valid here (auth failures are already handled as 401/403), and the request path is a hardcoded constant — a 404 on this endpoint can only mean "no calls in this window".Changes
fetch_pagenow treats a404whose body signals no calls ("no calls"substring) as an empty page — it returns an empty dict so the windowed iterator yields nothing and advances to the next window, instead of callingraise_for_status(). Genuine 404s with a different body still surface. Retryable (429/5xx) handling is unchanged.How did you test this code?
I'm an agent. I added a regression test at the same layer as the fix (
test_empty_window_returns_404): a windowedcallssync where the first window returns a 404 "no calls found" body and the second returns data — it asserts the sync skips the empty window, continues to the next, and returns the later window's rows rather than raising. No existing test exercised the 404-empty-window path (all windowed tests returned 200s).Ran the source's unit suite locally:
pytest products/warehouse_sources/backend/temporal/data_imports/sources/gong/tests/test_gong.py— 27 passed. Ruff check + format clean.Docs update
No docs change needed.
🤖 Agent context
Autonomy: Fully autonomous
Triaged from an error-tracking webhook for the
gongsource. Confirmed the stack originates ingong.py(get_rows→_iter_windowed_rows→fetch_pageat theraise_for_status()call), then verified against Gong's API behaviour that a 404 on/v2/callsmeans "no calls in the requested range", not a failure. Chose to fix the code (graceful skip) rather than add toNonRetryableErrors, because retrying or stopping the sync are both wrong — the window is simply empty and the sync should continue. Matched on the stable"no calls"body substring rather than the volatile status-only signal to avoid swallowing unrelated 404s. Skill invoked:/writing-tests.