Skip to content

[4.x] Fix YAML date coercion - #441

Merged
GrahamCampbell merged 2 commits into
4.xfrom
fix-yaml-date-coercion
Aug 23, 2026
Merged

[4.x] Fix YAML date coercion#441
GrahamCampbell merged 2 commits into
4.xfrom
fix-yaml-date-coercion

Conversation

@GrahamCampbell

Copy link
Copy Markdown
Contributor

This supersedes #439 and keeps its commit from @mklenbw as it was, rebased onto 4.x, followed by one commit with the changes that came out of review.

Unquoted date-shaped scalars like an IAM policy Version were parsed into Date objects and serialized into compiled templates as ISO 8601 strings, a date behind a file variable failed the whole configuration resolution, and date-shaped mapping keys became timezone-dependent strings. Quoted and !!str values were never affected. The schema change now also re-registers the timestamp type as explicit, so a deliberate !!timestamp tag keeps constructing a Date for consumers that read files through the utils and parser APIs instead of hard-failing with an unknown tag.

The same schema is applied on the two parse paths the original commit did not reach: serverless.utils.readFileSync previously used the date-coercing default schema for any file without CloudFormation shorthand tags, and yamlParser.parse loaded external $ref documents with no schema at all, which also made shorthand tags silently fail to resolve there. One deliberate tightening: an unquoted date-only s3 lifecycle ExpirationDate or TransitionDate previously slipped through validation via the coercion and now fails it explicitly; the fix is to write the full timestamp. A companion pull request applies the same change to 3.x.

mklenbw and others added 2 commits August 23, 2026 22:56
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@GrahamCampbell
GrahamCampbell merged commit 99210bf into 4.x Aug 23, 2026
8 checks passed
@GrahamCampbell
GrahamCampbell deleted the fix-yaml-date-coercion branch August 23, 2026 22:24
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.

2 participants