Skip to content

fix(wordpress): treat REST API 404 as non-retryable - #68121

Merged
Gilbert09 merged 1 commit into
masterfrom
posthog-code/wordpress-404-non-retryable
Jul 3, 2026
Merged

fix(wordpress): treat REST API 404 as non-retryable#68121
Gilbert09 merged 1 commit into
masterfrom
posthog-code/wordpress-404-non-retryable

Conversation

@Gilbert09

Copy link
Copy Markdown
Member

Problem

The WordPress data warehouse source raises an uncaught HTTPError when a wp/v2 collection returns 404. Seen in error tracking on the /users endpoint:

HTTPError: 404 Client Error: Not Found for url: <redacted>/wp-json/wp/v2/users?per_page=100&orderby=id&order=asc

It originates in wordpress.py fetch_page at response.raise_for_status(), so the sync fails and Temporal retries it repeatedly — burning retries and re-surfacing as error-tracking noise — for a condition that will never resolve on its own.

A per-endpoint 404 here is a customer-side config issue, not our bug. The base site URL is already validated against /posts at source setup, so by sync time the REST root is known-good. A 404 on a specific collection means that collection is disabled or blocked on the site. This is very common for /wp-json/wp/v2/users, which security plugins and managed hosts routinely block to prevent user enumeration.

Error tracking issue: https://us.posthog.com/project/2/error_tracking/019f26df-2192-7bf0-8c1f-7323cef731f5

Changes

Add 404 Client Error to WordpressSource.get_non_retryable_errors, mirroring the existing 401/403 entries. The sync stops retrying, disables the affected schema, and surfaces an actionable message pointing at the blocked endpoint (and how to fix it or drop the table from the sync) instead of a raw stack trace.

Scoped strictly to this: the substring 404 Client Error is stable and carries no volatile URL, id, or timestamp. It disables only the failing schema, not the whole source, so other collections keep syncing.

How did you test this code?

Automated tests only (agent — no manual sync performed):

  • Extended the existing parametrized TestWordpressSource::test_non_retryable_errors with a 404 Client Error case. It guards the regression where someone drops the 404 mapping and WordPress imports against a site that blocks a collection retry indefinitely. Extended rather than added a new function since the assertion is identical to the 401/403 cases.
  • Ran the test (3 passed) and ruff check / ruff format on the two changed files.

Automatic notifications

  • Publish to changelog?
  • Alert Sales and Marketing teams?

Docs update

No docs change needed. The in-product source caption is unchanged and still accurate; this only affects the runtime error message on a failed sync.

🤖 Agent context

Autonomy: Fully autonomous

Authored by Claude Code (Opus 4.8) from an error-tracking webhook. Invoked the /writing-tests skill before touching the test file to apply the value gate — the change is a single parametrized case, not a new test.

Decision: I weighed a graceful per-endpoint skip vs. marking 404 non-retryable, and chose non-retryable. A 404 is deterministic (retrying can't help) and, since the REST root is already validated at setup, a sync-time 404 is a blocked/disabled collection — an upstream config issue best surfaced to the user with the schema disabled, exactly like the existing 401/403 handling. Checked against open PR #68046, which only reworks the 403 messaging and does not touch 404, so this is not a duplicate.

A 404 from a wp/v2 collection means that endpoint is disabled or blocked
on the customer's site (security plugins commonly block /users to prevent
user enumeration). The base URL is already validated against /posts at
setup, so a per-endpoint 404 at sync time is upstream config, not a
transport blip. Retrying is pointless, so surface an actionable message
and stop the schema from retrying.

Generated-By: PostHog Code
Task-Id: 8f191cf8-87a9-47dc-9ea8-248890968430
@github-actions

github-actions Bot commented Jul 3, 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. 🙂

@pr-assigner-resolver-posthog
pr-assigner-resolver-posthog Bot requested a review from a team July 3, 2026 07:58
@greptile-apps

greptile-apps Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Reviews (1): Last reviewed commit: "fix(wordpress): treat REST API 404 as no..." | Re-trigger Greptile

@Gilbert09 Gilbert09 added the stamphog Request AI approval (no full review) label Jul 3, 2026 — with PostHog

@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.

Trivial, well-scoped fix adding a non-retryable error mapping with matching test update; author owns the code and bot reviewers (greptile, hex-security) signaled approval.

@Gilbert09
Gilbert09 merged commit 49bc75a into master Jul 3, 2026
303 checks passed
@Gilbert09
Gilbert09 deleted the posthog-code/wordpress-404-non-retryable branch July 3, 2026 08:47
@deployment-status-posthog

deployment-status-posthog Bot commented Jul 3, 2026

Copy link
Copy Markdown

Deploy status

Environment Status Deployed At Workflow
dev ✅ Deployed 2026-07-03 09:17 UTC Run
prod-us ✅ Deployed 2026-07-03 09:38 UTC Run
prod-eu ✅ Deployed 2026-07-03 09:43 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.

1 participant