Skip to content

fix: tighten AgreementStartDate CFN pattern + strptime safety (§1.129, §1.130)#30

Merged
hyunsies merged 1 commit into
mainfrom
fix/pr31-cfn-date-pattern
Apr 24, 2026
Merged

fix: tighten AgreementStartDate CFN pattern + strptime safety (§1.129, §1.130)#30
hyunsies merged 1 commit into
mainfrom
fix/pr31-cfn-date-pattern

Conversation

@hyunsies
Copy link
Copy Markdown
Contributor

Summary

Closes §1.129, §1.130 — CFN date pattern + strptime safety.

  • Replace weak `^\d{4}-\d{2}-\d{2}$` with `^(19|20)\d{2}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$` on `AgreementStartDate` (main YAML + configurator).
  • Mirror same tightening on `AgreementEndDate` in configurator (same class of bug — both date params).
  • Wrap `datetime.strptime()` in try/except `ValueError` in 3 places: `is_after_agreement` (main YAML Lambda), `is_within_agreement` (configurator Lambda), backfill `start_time` parsing (configurator backfill Lambda).
  • On `ValueError`: log + return False (event treated as out-of-scope). Do NOT raise / DLQ — stack is operator-broken, customer must redeploy, so DLQ spam is noise not signal.

Severity re-scope: CRITICAL → MEDIUM

Phase 16's evidence (5,339 DLQ from `2024-13-01`) came from raw-YAML deploy bypassing the configurator's CFN AllowedPattern. In the real customer path, CFN rejects invalid dates at stack creation, so this is a defense-in-depth fix, not a runtime-severity bug.

Verify-flag results

  • (1) Severity re-scoped (see above).
  • (2) Kept scope narrow to date params only. MpeId at :18 already has `^mig[a-zA-Z0-9]+$` — not touched.
  • (3) On ValueError: log + return (not DLQ). Confirmed rationale in commit.
  • (4) No overlap with PR fix: remove dead cross-account code path (H1, Wave 14 Option A) #35's MpeId guard — this PR touches dates only.

Regex validation (tested locally)

Input Matches
`2024-01-01` ✓ pass
`2024-12-31` ✓ pass
`2024-13-01` ✗ reject (month > 12)
`2024-01-32` ✗ reject (day > 31)
`1899-01-01` ✗ reject (year < 1900)
`2100-01-01` ✗ reject (year > 2099)
`2024-02-30` ✓ pass (still semantically invalid; caught by strptime try/except)

Test plan

  • `python3 .github/scripts/sync-check.py` passes
  • Regex tested locally with 9 cases
  • E2E green on this branch

…cept (§1.129, §1.130)

CFN AllowedPattern:
- Replace ^\d{4}-\d{2}-\d{2}\$ with stricter pattern that rejects month>12
  and day>31 at CFN parameter validation.
- Applied to AgreementStartDate in main YAML and both AgreementStartDate
  + AgreementEndDate in configurator.html embedded template (same class
  of bug on both date params).

Lambda strptime safety:
- Wrap datetime.strptime() calls in try/except ValueError.
- On ValueError: log + return (event treated as out-of-scope). Do NOT
  raise / DLQ — stack is operator-broken, customer must redeploy, so
  DLQ spam is noise not signal.
- Applied to is_after_agreement (main YAML), is_within_agreement
  (configurator), and the backfill start_time parsing (configurator).

Severity re-scoped CRITICAL → MEDIUM: CFN AllowedPattern already enforced
at stack creation, so Phase 16's 5,339 DLQ came from raw-YAML deploy
bypassing the configurator — not a real customer path.
@hyunsies hyunsies merged commit 7f3a255 into main Apr 24, 2026
117 of 126 checks passed
@hyunsies hyunsies deleted the fix/pr31-cfn-date-pattern branch April 24, 2026 08:29
hyunsies added a commit that referenced this pull request Apr 24, 2026
CHANGELOG stopped at PR #25 (v20.3.0) but the repo shipped 9 more PRs this
cycle. VERSIONING.md's example list and "source of truth" version constant
were also stale. Bringing both current:

- New v20.4.0 entry covering #37 (three-path classifier) and #38 (scope-
  intersection preflight), with a docs cross-reference to the #36
  reconciliation Lambda design.
- New v20.3.1 umbrella entry for the PATCH-class fixes shipped against
  v20.3.0: #29 (log retention), #30 (date pattern), #33 (CRITICAL scope
  fixes), #34 (SNS backfill helper), #35 (cross-account rip-out). Grouped
  retroactively — each shipped individually without a version bump.
- VERSIONING.md examples list updated to include session PRs per their
  MINOR / PATCH classification.
- VERSIONING.md "source of truth" constant bumped v20.1.0 → v20.4.0.

Pure docs; no runtime / CFN / IAM change. sync-check passes.

Co-authored-by: Chris Hyu <chhyu@amazon.com>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

1 participant