Skip to content

[#55] Fix cron backfill silently swallowing DB errors#56

Merged
realproject7 merged 2 commits intomainfrom
task/55-backfill-error-handling
Mar 14, 2026
Merged

[#55] Fix cron backfill silently swallowing DB errors#56
realproject7 merged 2 commits intomainfrom
task/55-backfill-error-handling

Conversation

@realproject7
Copy link
Copy Markdown
Owner

Summary

  • All upsert() calls now destructure { error } and throw on failure, so DB errors are caught by the existing try/catch and reflected in the errors response field
  • Cursor update checks for errors and logs failures
  • Removed 3 unused imports (plotChainedEvent, storylineCreatedEvent, donationEvent)

Fixes #55

Test plan

  • Verify npm run lint passes
  • Verify npm run typecheck passes
  • Confirm backfill endpoint returns accurate error counts when DB failures occur

🤖 Generated with Claude Code

All upsert calls now destructure { error } and throw on failure,
so DB errors are caught by the existing try/catch and counted in
the errors response field. Cursor update also checks for errors.
Removed 3 unused imports (plotChainedEvent, storylineCreatedEvent,
donationEvent).

Fixes #55

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

APPROVE

Verified all 4 acceptance criteria:

  1. Upsert error checks — All 4 upsert calls (storyline, genesis plot, plot, donation) now destructure { error } and throw on failure. Thrown errors bubble up to the existing try/catch in the main loop, correctly incrementing the errors counter.

  2. Error counter accuracy — DB failures now throw → caught by the same catch block that handles decode/IPFS failures → errors response field reflects both types. Good.

  3. Cursor update — Checked with console.error (not throw) — correct choice since cursor failure shouldn't abort the response after successful processing.

  4. Unused imports removedplotChainedEvent, storylineCreatedEvent, donationEvent cleaned up.

Minor note (non-blocking): If processStorylineCreated succeeds on the storyline upsert but fails on the genesis plot upsert, the storylinesInserted counter won't increment even though the storyline row was written. This is a minor reporting inaccuracy in an edge case — not worth blocking.

Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: REQUEST CHANGES

Summary

The PR fixes error counting for failed upserts and the CI checks are green, but it still does not satisfy the issue requirement to log per-event failures.

Findings

  • [medium] Per-event database/decode failures are still swallowed without any log output.
    • File: src/app/api/cron/backfill/route.ts:156
    • Suggestion: Capture the thrown error in the loop (catch (error)) and log enough context to diagnose the failed log before incrementing errors. Right now the new throw new Error(...) messages from the upserts are discarded immediately by the bare catch, so operators only get a count with no actionable detail.

Decision

Requesting changes because issue #55 explicitly requires failures to be logged/count failures, and the current loop only counts them.

Addresses T2a review: bare catch now captures the error and logs
tx hash + log index for operator diagnosis instead of silently
incrementing the counter.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

APPROVE (re-review)

Bare catch now logs tx hash + logIndex + error message — good for debugging failed backfill runs. All previous approvals still hold. Ship it.

Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: APPROVE

Summary

The follow-up commit fixes the remaining review gap by logging per-event failures with transaction context before incrementing the error counter. The PR now satisfies issue #55 and the lint/typecheck workflow passed.

Findings

  • None.

Decision

Approving because the backfill now both counts and logs database/decode failures, checks cursor update errors, removes the unused imports, and passes CI.

@realproject7 realproject7 merged commit 3ab094c into main Mar 14, 2026
1 check passed
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.

[BUG] Cron backfill silently swallows database errors

2 participants