{"id":"XE-12802","kind":"bounty","visibility":"public","source":"web","source_repo":"","source_ref":"","source_url":"","reporter_id":2235,"title":"Missing reconciliation of deleted GitHub source issues in the desk leaves stale ticket state and dead links","area":"other","claimed_tier":"minor","assessed_tier":null,"verdict":null,"duplicate_of":null,"tracked":false,"internal_ref":"","internal_url":null,"status":"triaging","closed_reason":null,"github_state":"","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-11-14T12:10:49.360934+00:00","updated_at":"2026-11-20T19:46:45.220693+00:00","source_created_at":null,"told_at":"2026-11-20T19:45:52.337466+00:00","status_changed_at":"2026-11-20T19:45:46.565212+00:00","url":"https://bounty.xe.network/XE-12802","body":"## Summary\r\n11 of the 196 GitHub-sourced tickets (5.6%) point at GitHub issues that no longer exist on public GitHub. The desk never notices: its poll only reads the issue listing, so an issue that vanishes from the listing is never revisited. The 11 tickets keep a stale `github_state`, keep a `source_url` that 404s, and keep `writes_to_issue` true, so the worker keeps attempting writes to the dead issues (every attempt fails). The only signal is a `reply.mirror_failed` event buried in each ticket's log.\r\n\r\n## Evidence (live, verified 2026-11-14)\r\n- Full enumeration: all 196 github-sourced tickets' `source_ref`s vs the complete live issue list of `xeprotocol/xe` (361 issues + 185 PRs = 546 items; list ends with a 0-item page 7, so the enumeration is complete). Exactly 11 refs are absent: #195-#202 and #241-#243, corresponding to XE-0119, XE-0120, XE-0121, XE-0122, XE-0123, XE-0124, XE-0125, XE-0126, XE-0258, XE-0259, XE-0260. All 11 are status `triaging`; `github_state` open on 8, closed on 3.\r\n- Direct GETs confirm: GET /repos/xeprotocol/xe/issues/200 returns HTTP 404, /202 returns 404, /241 returns 404 (API and web). The web URLs return 404 with no redirect, so the issues were NOT transferred to another repo (a transfer 301s to the new location).\r\n- The issues DID exist. Desk records prove it: all 11 tickets were created by the poll from live issues (cluster A XE-0119-XE-0126 created 2026-10-29 16:28-16:53 UTC; cluster B XE-0258-XE-0260 created 2026-11-02 21:17 UTC). Cluster B additionally has `github.state` + `github.closed_externally` events 2026-11-02 21:34, proving the poll READ issues #241-#243 as closed that day. They vanished between then and 2026-11-08 20:18-20:19, when all 11 replies failed to mirror with GitHub 422 `Validation Failed IssueComment.data: unprocessable` (the same 11 tickets, perfect correlation; the 422s are the symptom of commenting on a gone issue).\r\n- Ticket pages still show the dead link and stale state, e.g. XE-0124: `source_url: https://github.com/xeprotocol/xe/issues/200` (404), `github_state: open`; XE-0258: `source_url: .../issues/241` (404), `github_state: closed`.\r\n- The rest of the sync is healthy: in the 36-ticket sample, the other 32 tickets match live GitHub 32/32 on title, 32/32 on state, 32/32 on labels. The defect is confined to vanished issues, not a general sync failure.\r\n\r\n## Root cause (desk HEAD ab9df7f)\r\n- `import_repo` (desk/services/sync.py:392-445) iterates only `client.issues(repo, since=since)`, the listing only. `upsert_issue` refreshes facts only for issues present in the listing. An issue absent from the listing is never revisited: no dead-link detection, no `github_state` refresh, no event.\r\n- `writes_to_issue` (sync.py:717-723) gates writes only on source == \"github\" and source_repo and visibility == \"public\". It never checks the issue still exists. So the worker keeps attempting comments/labels on dead issues; each attempt fails (comment gives 422, recorded as `reply.mirror_failed` with mirror=\"failed\", terminal, no retry).\r\n- `GitHubError` (desk/services/github.py:51-56) faithfully reports the 422; the failure is recorded but nothing escalates a vanished source issue to the team.\r\n\r\n## Reproduction\r\n1. GET https://bounty.xe.network/v1/tickets?status=all&kind=all&limit=500 (paginate) and take the 196 source=github tickets.\r\n2. GET https://api.github.com/repos/xeprotocol/xe/issues?state=all&per_page=100&page=N (pages 1-7): 361 live issues. Diff the source_ref set against live issue numbers: 11 missing (#195-#202, #241-#243).\r\n3. GET https://api.github.com/repos/xeprotocol/xe/issues/200 returns 404; same for #202, #241.\r\n4. GET https://bounty.xe.network/v1/tickets/XE-0124: source_url 404s, github_state: open; its log shows reply.mirror_failed 2026-11-08 20:19 with the GitHub 422.\r\n\r\n## Mitigation\r\nOn poll, reconcile absence: when a ticket's source issue is missing from the listing (or when a write to it fails with 404/422), mark the ticket (github_state \"gone\" or equivalent, plus a github.vanished event and a team-visible note), stop write attempts to it (writes_to_issue false while gone), and surface it, so the team, not a buried log event, learns the outbound leg is broken. A cheap variant: on any mirror_failed / push_labels failure with 404/422, verify the issue with a single GET and mark it gone if absent.\r\n\r\n## Duplicate check\r\nLive desk searches (2026-11-14) all total 0: \"vanished issue\", \"deleted issue\", \"dead link\", \"source issue gone\", \"github_state stale\", \"transferred issue\", \"missing GitHub issue\", \"mirror failed\", \"issue deleted\", \"poll deleted\". q=\"mirror_failed\" returns 3, all different (XE-9301 Discord mirror transient fetch failure; XE-2332 reply.mirror_failed events leak GitHub error strings; XE-0768 event-log info disclosure). q=\"source_ref\" returns 12, none about vanished sources (closest XE-9036: Discord poison-row stall from an EMPTY source_ref, different component and cause). /v1/tickets/XE-0124/similar returns 0 results. Novel.\r\n\r\n## Severity\r\nMinor, CVSS 3.1 AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:N = 0.0. No confidentiality, integrity, or availability impact on the system itself. The impact is sync-state integrity on the desk's own records: stale github_state, dead source links, and silently broken outbound GitHub writes for the affected tickets.","patch_refs":[],"thread":[{"id":15267,"source":"desk","source_ref":"reply:13158","author":"Joseph Denne","team":true,"body":"Thanks for the report. It has been read against the current code and is being handled. The assessment and any award follow the fix.","created_at":"2026-11-20T19:45:52.311880+00:00"}]}