fix(calendar): reject inverted appointment time range on update (PMS-343) #253

Merged
vas2000-work merged 1 commit from fix/PMS-343-appointment-time-range into main 2026-06-16 00:57:48 +02:00
Owner

What

Reject inverted (end before start) appointment time ranges on the update path. create_appointment already enforced end_time > start_time at the service layer, but update_appointment did not, so a partial PUT (e.g. only end_time) could invert an appointment's range against its stored values.

Changes

  • Extract a shared appointment_range_ok(start, end) helper in calendar/models.rs, with unit tests (end-after-start ok, end-before-start rejected, zero-length rejected).
  • create_appointment now calls the helper (behavior unchanged: rejects end <= start).
  • update_appointment loads the current start/end, computes the effective range (request value when provided, else the stored value), and rejects an inverted range before writing.

Testing

  • cargo test --lib (dev container): 3 new range tests pass; full lib compiles.
  • cargo clippy --all-targets -- -D warnings: clean.
  • cargo fmt --all --check: clean.

Note on the issue

PMS-343 described the create path as unguarded; on inspection, create was already guarded at the service layer, so the real gap (and the substance of this fix) was the update path. The shared helper keeps both paths consistent. (Issue record corrected with a comment.)

## What Reject inverted (end before start) appointment time ranges on the update path. `create_appointment` already enforced `end_time > start_time` at the service layer, but `update_appointment` did not, so a partial PUT (e.g. only `end_time`) could invert an appointment's range against its stored values. ## Changes - Extract a shared `appointment_range_ok(start, end)` helper in `calendar/models.rs`, with unit tests (end-after-start ok, end-before-start rejected, zero-length rejected). - `create_appointment` now calls the helper (behavior unchanged: rejects `end <= start`). - `update_appointment` loads the current start/end, computes the effective range (request value when provided, else the stored value), and rejects an inverted range before writing. ## Testing - `cargo test --lib` (dev container): 3 new range tests pass; full lib compiles. - `cargo clippy --all-targets -- -D warnings`: clean. - `cargo fmt --all --check`: clean. ## Note on the issue PMS-343 described the create path as unguarded; on inspection, create was already guarded at the service layer, so the real gap (and the substance of this fix) was the update path. The shared helper keeps both paths consistent. (Issue record corrected with a comment.)
fix(calendar): reject inverted appointment time range on update (PMS-343)
All checks were successful
E2E / Playwright against staging (pull_request) Successful in 37s
Check / fmt + clippy + compile + unit/doc tests (pull_request) Successful in 1m17s
Integration / integration tests (pull_request) Successful in 3m10s
Create release / Create release from merged PR (pull_request) Has been skipped
d3be6959b6
create_appointment already rejected end_time <= start_time at the service layer, but the update path did not, so a partial PUT could invert an appointment's range against its stored values. This extracts a shared appointment_range_ok helper used by both create and update, validates the effective (request-or-stored) range in update_appointment before writing, and adds unit tests for the range check.

#PMS-343

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
vas2000-work deleted branch fix/PMS-343-appointment-time-range 2026-06-16 00:57:48 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
psa-systems/mokosh-server!253
No description provided.