Skip to content

refactor: simplify Fn::Select lifecycle policy error metadata - #4711

Merged
kddejong merged 1 commit into
aws-cloudformation:mainfrom
kddejong:fix/lifecycle-policy-select-error-consistency
Sep 16, 2026
Merged

kddejong merged 1 commit into
aws-cloudformation:mainfrom
kddejong:fix/lifecycle-policy-select-error-consistency

Conversation

@kddejong

Copy link
Copy Markdown
Contributor

Description

Follow-up cleanup to #4704 (reject Fn::Select lifecycle policies without a transform).

The UpdatePolicy rejection in updatepolicy/Configuration.py was emitting a hardcoded schema_path:

schema_path=["allOf", 0, "then", "properties", "UpdatePolicy", "type"]

That path does not correspond to update_policy.json:

  • allOf[0].then.properties.UpdatePolicy is a $ref node with no type key, so the trailing type segment points at nothing.
  • allOf[0] is specifically the AWS::AutoScaling::AutoScalingGroup branch, so the path misrepresents the other four resource types (Lambda::Alias, Elasticsearch/OpenSearch Domain, ElastiCache::ReplicationGroup, AppStream::Fleet).

The sibling CreationPolicy.py (E3055) emits the same class of error without any schema_path, so this drops the fabricated schema_path and validator_value to make both lifecycle-policy rules emit the same minimal error shape. The justified path=["UpdatePolicy"] / instance=... are kept, since E3016 validates the whole Resources/* object and the error belongs on the UpdatePolicy child.

Also adds a short comment to both rules explaining why Fn::Select is special-cased at these slots (it declares an all_types output, so the generic output-type check from #4641 treats it as object-compatible).

No behavior change: E3055/E3016 still fire on a bare Fn::Select without AWS::LanguageExtensions and stay silent with it.

Tests

  • pytest test/unit/rules/resources/test_creationpolicy.py test/unit/rules/resources/updatepolicy/test_configuration.py test/unit/rules/functions/test_select.py — 34 passed
  • ruff check + ruff format --check on the changed files — clean
  • End-to-end lint confirms E3055 + E3016 fire without the transform and are suppressed with Transform: AWS::LanguageExtensions

Follow-up to aws-cloudformation#4704. The UpdatePolicy Fn::Select rejection carried a
hardcoded schema_path (allOf/0/then/properties/UpdatePolicy/type) that
does not match the schema: that node is a $ref with no `type` key, and
allOf[0] is the AutoScaling branch only, so it misrepresents the other
resource types. Drop the fabricated schema_path and validator_value so
both lifecycle-policy rules emit the same minimal error shape, and add a
comment explaining why Fn::Select is special-cased at these slots.

aws-cloudformation#4645
@codecov

codecov Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.67%. Comparing base (57a1aec) to head (3805c64).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4711   +/-   ##
=======================================
  Coverage   94.67%   94.67%           
=======================================
  Files         435      435           
  Lines       15586    15586           
  Branches     3021     3021           
=======================================
  Hits        14756    14756           
  Misses        453      453           
  Partials      377      377           
Flag Coverage Δ
unittests 94.67% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@kddejong
kddejong merged commit 5fd57cb into aws-cloudformation:main Sep 16, 2026
21 checks passed
@kddejong
kddejong deleted the fix/lifecycle-policy-select-error-consistency branch September 16, 2026 17:02
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