Skip to content

Slack sync: tighter safety-backfill + stale-source warner - #817

Open
henry-dowling wants to merge 1 commit into
mainfrom
slack-sync-freshness
Open

Slack sync: tighter safety-backfill + stale-source warner#817
henry-dowling wants to merge 1 commit into
mainfrom
slack-sync-freshness

Conversation

@henry-dowling

Copy link
Copy Markdown
Collaborator

Why

Our Slack integration went stale and I traced it in prod (Neon stash-prod + Render logs). Freshness has two paths: the live Events-API webhook (/api/v1/integrations/slack/eventsingest_slack_event) and a periodic safety backfill (index_slack). Today the webhook delivered zero events (Slack isn't POSTing us — a separate config fix in the Slack app console), so the only thing keeping data fresh was a 6-hour backfill. A message posted at 17:47 UTC didn't land until the next backfill window — it was invisible for hours.

Separately, a duplicate Slack source (owner sam@) had been failing on every run since June 12 (RuntimeError: no allowed channels configured) with no signal anywhere.

This PR doesn't fix the webhook (that's Slack-app config), but it makes the fallback tight and makes silent staleness visible.

Changes

  • Tighten the Slack safety-backfill interval DEFAULT_SYNC_INTERVAL_S["slack"] 21600s (6h) → 1800s (30m). When the webhook is down, worst-case staleness is minutes, not a quarter-day. Cost is ~1 conversations.history call per allowlisted channel per 30m — comfortably within Slack limits.
  • source_service.stale_sources() + hourly warn_stale_sources beat task. Logs a WARNING for any sync_enabled source that is currently failing (sync_error set), never completed (last_synced_at IS NULL), or last succeeded more than 3 intervals ago. The month-dead Slack source would have surfaced on day one.

Scope / limitations (deliberate)

  • This does not detect the specific "webhook silent, backfill still succeeding" case (last_synced_at stays fresh). The mitigation for that is the tighter interval above + fixing the Events subscription in the Slack console; a per-source expected-cadence check would be over-engineering here.
  • Does not touch the misconfigured sam@ duplicate source — that's a data cleanup (configure its channel allowlist or delete it), handled separately, not a code change. The new warner will now flag it every hour until it's resolved.

Test

pytest backend/tests/test_sources.py → 89 passed. New test_stale_sources_flags_failing_and_overdue covers failing/overdue/fresh. One failure (test_provider_cleanup_removes_source_and_retained_rows[posthog-posthog_project]) is pre-existing and unrelated — it fails identically on the base commit with my changes stashed. ruff check / ruff format --check clean.

Backend-only; no GUI changes.

🤖 Generated with Claude Code

The Slack Events-API webhook is the live ingestion path; a plain
6-hour backfill was the only fallback. When the webhook stopped
delivering, a channel could sit up to 6h stale with no signal — and a
second Slack source that had been failing every run went unnoticed for
a month.

- Drop the Slack safety-backfill interval from 21600s (6h) to 1800s so
  worst-case staleness when the webhook is down is minutes, not hours.
- Add source_service.stale_sources() + a hourly warn_stale_sources beat
  task that logs any enabled source that is failing, never synced, or
  last succeeded more than 3 intervals ago, so a dead token / wedged
  reconciler surfaces instead of rotting silently.

Test: pytest backend/tests/test_sources.py (89 passed; one unrelated
pre-existing posthog-cleanup failure). ruff clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@assert-app

assert-app Bot commented Jul 15, 2026

Copy link
Copy Markdown

@vercel

vercel Bot commented Jul 15, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
stash-web Ready Ready Preview, Comment Jul 15, 2026 8:18pm

Request Review

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant