Skip to content

fix(gong): treat empty calls window 404 as no data#67264

Merged
Gilbert09 merged 2 commits into
masterfrom
posthog-code/gong-empty-window-404
Jul 1, 2026
Merged

fix(gong): treat empty calls window 404 as no data#67264
Gilbert09 merged 2 commits into
masterfrom
posthog-code/gong-empty-window-404

Conversation

@Gilbert09

Copy link
Copy Markdown
Member

Problem

Gong data-warehouse imports were failing with an unhandled HTTPError raised from the source's fetch_page (error tracking issue):

HTTPError: 404 Client Error: Not Found for url: https://api.gong.io/v2/calls?fromDateTime=<redacted>&toDateTime=<redacted>

Gong's /v2/calls endpoint answers a date window that contains no processed calls with a 404 ({"errors": ["No calls found corresponding to the provided filters"]}) rather than an empty 200. This is documented, expected behaviour — the endpoint only returns completed calls, so a range with none returns 404.

The calls schema 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_page now treats a 404 whose 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 calling raise_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 windowed calls sync 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 gong source. Confirmed the stack originates in gong.py (get_rows_iter_windowed_rowsfetch_page at the raise_for_status() call), then verified against Gong's API behaviour that a 404 on /v2/calls means "no calls in the requested range", not a failure. Chose to fix the code (graceful skip) rather than add to NonRetryableErrors, 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.

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
Copilot AI review requested due to automatic review settings July 1, 2026 07:15
@Gilbert09 Gilbert09 added the stamphog Request AI approval (no full review) label Jul 1, 2026
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Hey @Gilbert09! 👋

It looks like your git author email on this PR isn't your @posthog.com address (owerstom@gmail.com). Since you're on the PostHog team, it's worth pointing your local git author email at your @posthog.com address. Why it matters:

  • Consistent work identity in git history — internal tooling that attributes commits to team members keys off your @posthog.com address.
  • Keeps team contributions easy to tell apart from external community ones when scanning history.

You can fix it for this repo with:

git config user.email "you@posthog.com"

Or set it globally with git config --global user.email "you@posthog.com". No need to redo this PR — just a nudge for next time. 🙂

github-actions[bot]
github-actions Bot previously approved these changes Jul 1, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Safe, narrow fix for a Gong API quirk with a matching test. The guard condition is specific enough (404 + body contains "no calls") to avoid swallowing unrelated errors.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_page to 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 calls sync 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.

@greptile-apps

greptile-apps Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

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
@github-actions github-actions Bot dismissed their stale review July 1, 2026 07:33

New commits pushed (delta classified non_trivial_delta) — stamphog approval dismissed; re-review running automatically.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@Gilbert09 Gilbert09 merged commit 12b8140 into master Jul 1, 2026
212 checks passed
@Gilbert09 Gilbert09 deleted the posthog-code/gong-empty-window-404 branch July 1, 2026 12:27
@deployment-status-posthog

deployment-status-posthog Bot commented Jul 1, 2026

Copy link
Copy Markdown

Deploy status

Environment Status Deployed At Workflow
dev ✅ Deployed 2026-07-01 13:07 UTC Run
prod-us ✅ Deployed 2026-07-01 13:22 UTC Run
prod-eu ✅ Deployed 2026-07-01 13:27 UTC Run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stamphog Request AI approval (no full review)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants