All problems

An Expired Tool Hold Can Still Be Confirmed

Level 2 · node · Reliability · Missing expiry check in temporary hold confirmation

Scenario

A fictional workplace tool-loan service creates temporary holds for equipment. Each hold has a numeric expiration time, and a confirmation request supplies the current time. A pending hold must not be confirmed after expiration, but the current implementation checks only its status. Follow the repository, service, and controller flow.

Requirements

Reject confirmation when the supplied current time is greater than or equal to the hold's expiration, without changing its stored status. Preserve confirmation of valid pending holds, errors for already confirmed or unknown holds, and independence between holds. Use the supplied now value without accessing the system clock or adding packages.

Acceptance criteria

  • A hold whose expiry is at or before the supplied current time cannot be confirmed and remains unchanged.
  • A pending hold before its expiry can be confirmed.
  • An already confirmed hold cannot be confirmed again.
  • An unknown hold returns an error.
  • An expiry exactly equal to the current time counts as expired.
  • Processing one hold does not change any other hold.