Skip to content

Commit aee55b5

Browse files
Shukriclaude
authored andcommitted
fix: add ingest validation and missing stats query indexes
- ingest: reject payloads with neither exception nor message (400) - migration: add (status, last_seen), (status, first_seen, last_seen) indexes for stats filtered counts, and bare created_at index on events for the global 24h count Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent e7480f1 commit aee55b5

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
-- ── Stats query indexes ───────────────────────────────────────────────────────
2+
-- Supports COUNT(*) FILTER (WHERE status = '...' AND last_seen > NOW() - INTERVAL '24 hours')
3+
CREATE INDEX IF NOT EXISTS idx_issues_status_last_seen ON issues(status, last_seen DESC);
4+
5+
-- Supports the regressions_24h filter: first_seen + last_seen + status
6+
CREATE INDEX IF NOT EXISTS idx_issues_status_first_last ON issues(status, first_seen, last_seen DESC);
7+
8+
-- Supports global events count: COUNT(*) WHERE created_at > NOW() - INTERVAL '24 hours'
9+
-- (the existing idx_events_project_created requires a project_id match)
10+
CREATE INDEX IF NOT EXISTS idx_events_created ON events(created_at DESC);

src/routes/ingest.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,14 @@ pub async fn handle_ingest(
3030
.await?
3131
.ok_or_else(|| AppError::NotFound("Invalid API key".to_string()))?;
3232

33-
// 3. Push to Redis queue — return immediately (fire-and-forget)
33+
// 3. Basic payload validation — require at least one of exception or message
34+
if payload.exception.is_none() && payload.message.is_none() {
35+
return Err(AppError::BadRequest(
36+
"payload must include either 'exception' or 'message'".into(),
37+
));
38+
}
39+
40+
// 4. Push to Redis queue — return immediately (fire-and-forget)
3441
push_job(&state.redis_pool, EventJob {
3542
project_id: project.id,
3643
payload,

0 commit comments

Comments
 (0)