[16.0][FIX] pms: validate HH:MM hours with a single format check - #434
Merged
Merged
Conversation
DarioLodeiros
approved these changes
Aug 17, 2026
DarioLodeiros
left a comment
Member
There was a problem hiding this comment.
Reviewed the migration in detail: the normalization is idempotent (already-valid values pass through the lpad unchanged), '24:00' is mapped to '23:59', empty property hours are filled before the fields become required, and whatever cannot be normalized is logged for manual review instead of being guessed. The single validation helper on pms.property plus the defensive computes remove the positional int(hour_str[0:2]) parsing that crashed cancellation mails.
Note for deployers: char hour values that the migration logs as not normalizable still need manual fixing — the computes will reject them at runtime.
The hour fields accepted anything time.strptime(hour, "%H:%M") parsed,
including hours without zero padding ("8:00") that the consumers, which
read the hour by position, could not parse back.
A single regex validates them now, pms.property owns the only parser,
and the checkin and checkout datetime computes use it instead of slicing
the string. The property hours become required, and a pre-migration
normalizes the values already stored.
Assisted-by: Claude Opus 5
DarioLodeiros
force-pushed
the
16.0-fix-arrival-hour-format
branch
from
August 24, 2026 11:27
7df89c1 to
c2af07f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
The hour fields stored as
Char(pms.property.default_arrival_houranddefault_departure_hour,pms.reservation.arrival_houranddeparture_hour)were checked with
time.strptime(hour, "%H:%M"), which does not require zeropadding, so
"8:00"passed the check and was stored.The consumers read the hour by position, so
int(arrival_hour[0:2])isint("8:"): a value the check accepted raisedValueErrorin_compute_checkin_datetime, and everything readingcheckin_datetimefailedwith it, mail templates included.
Solution
One regex,
^([01]\d|2[0-3]):[0-5]\d$, replaces the fourstrptimecalls, andpms.propertyowns the only parser (is_valid_hour_str,hour_str_to_timeand
datetime_from_hour_str), used both by the checks and by the checkin andcheckout datetime computes, which no longer slice the string.
Those computes return no value when the date or the hour is missing, instead of
raising
TypeError, and the property hours become required: they always had adefault, and the empty branch only made the check raise.
Migration
The stricter check would leave the records holding an unpadded hour unwritable,
so
16.0.4.13.0/pre-migration.pynormalizes what is already stored:"9:00"to"09:00""24:00"becomes"23:59", keeping its end of day meaningguessing a value would be worse than reporting it