Skip to content

Validate notification expiration timestamps on registration - #112

Merged
Abd-Standard merged 1 commit into
Core-Foundry:mainfrom
michaelvic123:feat/validate-notification-expiry
Jun 20, 2026
Merged

Validate notification expiration timestamps on registration#112
Abd-Standard merged 1 commit into
Core-Foundry:mainfrom
michaelvic123:feat/validate-notification-expiry

Conversation

@michaelvic123

@michaelvic123 michaelvic123 commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

closes #96

What

Prevents registration of notifications with invalid or already-expired executeAt timestamps.

Changes

  • notification-api.ts — split the single vague guard into two checks:
    • Rejects non-Date or Invalid Date objects: executeAt must be a valid date
    • Rejects timestamps at or before now: executeAt must be a future timestamp — the provided date has already expired
  • events-server.ts — validates the raw executeAt string before constructing a Date, returning 400 early instead of passing an Invalid Date silently downstream
  • Tests — replaced the single past-date test with four boundary cases:
    • expired timestamp (60s ago)
    • timestamp equal to now (boundary)
    • new Date('not-a-date') (invalid Date object)
    • 1 second in the future (should pass)

Testing

npm test -- --testPathPattern=notification-scheduler

All 30 tests pass.

- reject invalid Date objects with a descriptive error
- reject timestamps at or before current time (expired)
- validate executeAt string in REST endpoint before Date construction
- add boundary tests: past, now, invalid date, 1s future
@Abd-Standard
Abd-Standard merged commit ee093f7 into Core-Foundry:main Jun 20, 2026
1 of 2 checks 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.

[Contracts] Validate Notification Expiration Windows

2 participants