Page MenuHomePhabricator

Investigate "Unknown Wiki Domain" errors
Closed, ResolvedPublic

Event Timeline

What the stack trace shows:

> $w = Wiki::where('domain', 'testtemptest.wikibase.dev')->withTrashed()->first()

= App\Wiki {#8452
    id: 7,
    domain: "testtemptest.wikibase.dev",
    sitename: "TestTempTest",
    deleted_at: "2021-11-18 15:29:51",
    created_at: "2021-11-18 15:26:45",
    updated_at: "2021-11-18 15:29:51",
    description: null,
    is_featured: 0,
    wiki_deletion_reason: null,
    +domain_decoded: "testtemptest.wikibase.dev",
  }

Why this can happen

  • Some wikis were soft-deleted. (using Wiki's SoftDeletes)
  • PollForMediaWikiJobsJob first loads all domains with Wiki::all()->pluck('domain') at PollForMediaWikiJobsJob.php:19.
  • Resolver then does a second lookup by domain with default scope (non-trashed only) at MediaWikiHostResolver.php:48.
  • If a wiki is deleted between those two queries, or the domain row is otherwise missing/inconsistent at that moment, the second query returns null and throws this exact exception.

Solution

  • use Wiki::whereNull('deleted_at')->pluck('domain') so soft-deleted rows are not considered in the first place
  • catch UnknownWikiDomainException inside per-wiki check and log any warnings instead of crashing the whole job
dang removed dang as the assignee of this task.Jul 30 2026, 3:18 PM
dang moved this task from Doing to Waiting for Peer Review on the Wikibase Cloud (Kanban Board) board.
dang updated the task description. (Show Details)
dang removed dang as the assignee of this task.Aug 3 2026, 11:11 AM
dang moved this task from Doing to Waiting for Peer Review on the Wikibase Cloud (Kanban Board) board.
NOTE: Please consider doing/reviewing other tasks in the policy topic. This one is not urgent and doesn't break our infrastructure.
dang triaged this task as Low priority.Aug 4 2026, 1:12 PM
Tarrow moved this task from In Peer Review to Todo on the Wikibase Cloud (Kanban Board) board.
Tarrow subscribed.
dang removed dang as the assignee of this task.
dang moved this task from Todo to Doing on the Wikibase Cloud (Kanban Board) board.
dang moved this task from Doing to Waiting for Peer Review on the Wikibase Cloud (Kanban Board) board.
dang removed dang as the assignee of this task.Aug 20 2026, 12:27 PM
dang moved this task from Doing to Waiting for Peer Review on the Wikibase Cloud (Kanban Board) board.
Tarrow changed the task status from Open to Stalled.Aug 28 2026, 12:41 PM
Tarrow removed Tarrow as the assignee of this task.

I guess we need to move this forwards; this is quite a complicated bit of our stack so I don't think we should ship it on a friday afternoon. Stalled until monday.

Tarrow changed the task status from Stalled to Open.Aug 31 2026, 8:10 AM

Monday; ready to go now

I wrote this comment as we discussed it in a recent daily but forgot to submit it 😅

For the reviewer:

  • Read through the ticket and the PR for context
  • Once deployed to staging check that the jobs continue to run successfully
  • Once successfully tested on staging, do the same on production
Ollie.Shotton_WMDE reassigned this task from Ollie.Shotton_WMDE to dang.

What? I just reordered this ticket in the Doing column and Phabricator triggers decided to assign me to the task, that's not what I would have expected! 🙈

The error still persists earlier this morning. Check the error log

Taking a look at the error, I believe that the resolver call is simply too early in the loop:
https://github.com/wbstack/api/blob/48104e2c80052fb9890ec8540c002c832b6d89d2/app/Jobs/PlatformStatsSummaryJob.php#L83

So I did some quick investigation, and here are the results:

Why the error still persists?

  • PlatformStatsSummaryJob resolves a backend URL for every wiki, even deleted ones
  • The resolver’s domain lookup uses Wiki::where(), which ignores soft-deleted rows, while this job intentionally includes trashed wikis

Added fix:

  • The resolver call is simply too early in the loop. I moved it behind the deleted-wiki logic
  • Added regression test
dang removed dang as the assignee of this task.Sep 7 2026, 7:55 AM
dang moved this task from Doing to Waiting for Peer Review on the Wikibase Cloud (Kanban Board) board.

I've updated PR#1246 with the changes made during pair review, demonstrated that the call to Http::fake() is not needed, and removed it from the test. Sorry that took so long. I've approved the PR, so if you're happy with the changes you can merge and deploy.


In the description of T433575, @dang wrote:

Follow-up PR due to persisted error due to order of execution:

I want to point out that PR#1246 is not a follow-up to PR#1221. The cloud logs indicating that PlatformStatsSummaryJob was (one of the places) causing "Unknown Wiki Domain" errors to be thrown go back way before PR#1221 was deployed on 2026-09-04:

image.png (1,864×861 px, 300 KB)

dati18 merged https://github.com/wbstack/api/pull/1246

fix: skip deleted wikis before resolving URLs in PlatformStatsSummaryJob

I went and confirmed that I saw no more errors since Monday! Nice! I know it took a while but this kind of cleaning and maintenance does have lots a value. Less logspam makes real issues much easier to identify.