Skip to content

Reject report_revenue override_existing=true on nonexistent periods instead of treating as initial #357

@thlpkee20-wq

Description

@thlpkee20-wq

Description

When report_revenue is called with override_existing=true for a period_id that has no prior persisted report, the override flag is effectively ignored and the call falls through to initial-report handling. This conflates "correct an existing period" with "create a new period" and can mask off-chain bugs. Make override_existing=true require an existing report, returning a typed error otherwise.

Requirements and context

  • Must be secure, tested, and documented
  • Should be efficient and easy to review
  • Relevant code: src/lib.rs (report_revenue match on reports.get(period_id))
  • The override path must still emit rev_ovrd and apply net delta to total_revenue without incrementing report_count

Suggested execution

  • Fork the repo and create a branch
  • git checkout -b feat/override-requires-existing-period
  • Implement changes
    • In the None arm, branch on override_existing and return a clear error (e.g. InvalidPeriodId or new variant)
    • Preserve existing initial-report behavior when override_existing=false
    • Update README report_revenue semantics
  • Validate security and correctness assumptions

Test and commit

  • Run tests
    • cargo test
  • Cover edge cases
    • override on new period, override on existing, initial then override, event_only mode
  • Include test output and security notes

Example commit message

feat: require existing period for report_revenue override_existing

Guidelines

  • Minimum 95 percent test coverage
  • Clear documentation
  • Timeframe: 96 hours

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions