Repository navigation
fix(formats): match an anyOf of formats on the source schema - #4832
Merged
kddejong merged 2 commits intoOct 22, 2026
Merged
Conversation
RefFormat/GetAttFormat compare the property schema (source) against the Ref/GetAtt return schema (destination). anyOf of formats was only honored on the destination; a property declaring an anyOf of formats was skipped entirely, so a wrong reference went unreported. Match when any source format is compatible with the destination, and report when none are.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4832 +/- ##
=======================================
Coverage 94.67% 94.67%
=======================================
Files 439 439
Lines 15985 15995 +10
Branches 3100 3104 +4
=======================================
+ Hits 15134 15144 +10
Misses 468 468
Partials 383 383
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Add cases for an anyOf source with no format keywords (unchecked) and an anyOf source against a destination with no format, covering the new branches in compare_schemas.
This was referenced Oct 22, 2026
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.
What
RefFormat(E1041) andGetAttFormat(E1040) compare the property schema (thesource) against the Ref/GetAtt return schema (thedestination) in_schema_comparer.compare_schemas. AnanyOfofformats was only honored on the destination: on the source, the entry point reads a singlesource.get("format")and returnsNone(no check) when it is absent. So a property that declares ananyOfof acceptable formats was not validated at all — a reference returning a matching format passed, but so did one returning a completely unrelated format.Fix
When the source schema has no plain
formatbut has ananyOfof formats, treat the property as compatible when the reference matches any listed format, and report when it matches none — mirroring the behavior the destination side already has via_any_of.Why
This is needed for properties that legitimately accept more than one referenced type. The motivating case is Route53
AliasTarget.HostedZoneId, which accepts either a service's canonical hosted-zone id (AWS::Route53::AliasTarget.HostedZoneId) or aRefto a hosted zone you own (AWS::Route53::HostedZone.Id) for a same-zone alias. The schema side is a companion change in resource-provider-enhanced-schemas (emits theanyOf); this PR is the engine support it depends on.Tests
test_schema_comparer: a sourceanyOfnow matches when any format is compatible and errors when none are (replacing the previous case that asserted a non-matching sourceanyOfwas silently valid), plus the Route53 positive/negative pair.test/unit/rules/formats,test_ref_format,test_getatt_format: 106 pass.test/fixtures/templates/goodcorpus (yaml + json), so no currently-clean template regresses.