Repository navigation
fix(sdk): compare payment.execution_date bounds as ISO 8601 values - #378
baaakgun4543 wants to merge 1 commit into
Conversation
ExecutionDateEvaluator compared raw strings. Executions outside the window were accepted when they sorted inside it (a negative UTC offset or fractional seconds after not_after, a positive offset before not_before), and valid ones were rejected (a date-only execution on the first day of the spec's example window). Parse ISO 8601 dates and date-times, compare instants (day granularity when either side is a date), and report invalid values instead of comparing them lexically.
|
Note on the failing #379 adds those terms to the dictionary. Once it is merged, re-running spellcheck here should pass. |
|
Related: #318 changes the same function, The two changes are complementary and will conflict textually. Whichever lands first, I'll rebase this one onto it. |
Description
ExecutionDateEvaluatorcomparesexecution_datewithnot_beforeandnot_afteras raw strings. The spec example window uses date-times with an offset ("not_before": "2026-03-31T00:00:00Z","not_after": "2026-04-30T23:59:59Z"), andpayment_mandate.execution_dateis an ISO 8601 date. Lexical order is not chronological order, so the check fails in both directions.Executions outside the window are accepted (fail-open). All three cases below use the spec example window:
execution_date2026-04-30T23:59:59-09:00not_after-sorts beforeZ2026-04-30T23:59:59.5Znot_after.sorts beforeZ2026-03-31T08:00:00+09:00not_beforeT00:00:00ZValid executions are rejected (fail-closed).
2026-03-31sorts before2026-03-31T00:00:00Z.2026-05-01T08:00:00+09:00, which is 2026-04-30T23:00Z and inside the window.Change
_parse_iso8601parsesYYYY-MM-DDas a date and anything else withdatetime.fromisoformat, which supportsZand fractional seconds on Python ≥ 3.11, the project minimum. Naive date-times are treated as UTC._compare_iso8601compares instants. If either side is a calendar date, both sides are compared as calendar dates, each taken in its own offset.The existing date-only tests (
within_window,before_window,after_window,missing_passes) are unchanged and pass.Tests
New tests in
constraints_tests.py:test_payment_execution_date_outside_window_is_rejected, parametrized over the three fail-open cases above.test_payment_execution_date_on_datetime_window_start, the spec example window.test_payment_execution_date_offset_compared_as_instant.test_payment_execution_date_offset_after_window, a regression guard that passes before and after.test_payment_execution_date_invalid_fails_closed.6 of the 7 new cases fail on
main.Full suite in a clean environment with the pinned dependencies (Python 3.12):
mainThe 2 failures are the
kb_sd_jwt_intermediate_tests.pyaud/nonce mismatch tests. They fail identically onmainand are unrelated. The change adds noruff checkfindings beyond those already onmain.If the
payment.budgetfix lands first, the only conflict is the adjacentdatetimeanddecimalimport lines.Open question (not changed here)
When
execution_dateis absent, the schema says this "indicates immediate execution". The evaluator currently skips the window check, andtest_payment_execution_date_missing_passespins that behaviour, even for a window entirely in the past. This PR leaves that alone; see #376.Related to #376
CONTRIBUTINGGuide.main).