Skip to content

[Bug] Deadline enforcement: missing has_deadline check + API uses wrong timestamp #808

@realproject7

Description

@realproject7

Problem

PR #807 introduced deadline enforcement but has two bugs:

Bug 1: has_deadline not checked (critical)

The deadline expiry logic is applied unconditionally to ALL storylines. Storylines created with has_deadline=false (no 7-day deadline) would be incorrectly blocked from creating new plots if their last_plot_time is old.

Affected locations:

  • src/components/AddPlotButton.tsxisDeadlineExpired() doesn't check has_deadline
  • src/app/create/page.tsxisStorylineExpired() doesn't check has_deadline
  • src/app/api/index/plot/route.ts — API query selects last_plot_time, sunset but not has_deadline

Bug 2: API uses Date.now() instead of block timestamp (edge case)

The API indexer checks Date.now() > deadline but this runs AFTER the on-chain tx already succeeded. A plot submitted at T-1 minute that the contract accepted could fail indexing if Date.now() has moved past the deadline by the time the API processes it.

Fix: Compare against the block timestamp (already fetched in the route) instead of Date.now().

Solution

  1. All three locations must check has_deadline === true before applying deadline logic
  2. AddPlotButton needs hasDeadline as a prop
  3. isStorylineExpired in create page should check s.has_deadline
  4. API route should select has_deadline and skip check when false
  5. API should compare block timestamp vs deadline, not Date.now()

Acceptance Criteria

  • Storylines with has_deadline=false are never blocked by deadline logic
  • AddPlotButton receives and checks hasDeadline prop
  • Create page isStorylineExpired checks has_deadline
  • API selects and checks has_deadline
  • API uses block timestamp instead of Date.now() for deadline comparison

Branch

task/<issue>-deadline-has-deadline-fix

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent/T3Assigned to T3 builder agentbugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions