From 3805c64fed6937884b1967ac8e579815a18713c6 Mon Sep 17 00:00:00 2001 From: Kevin DeJong Date: Tue, 15 Sep 2026 20:19:42 +0000 Subject: [PATCH] refactor: Simplify Fn::Select lifecycle policy errors Follow-up to #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. https://github.com/aws-cloudformation/cfn-lint/issues/4645 --- src/cfnlint/rules/resources/CreationPolicy.py | 4 ++++ .../rules/resources/updatepolicy/Configuration.py | 13 ++++--------- .../resources/updatepolicy/test_configuration.py | 9 --------- 3 files changed, 8 insertions(+), 18 deletions(-) diff --git a/src/cfnlint/rules/resources/CreationPolicy.py b/src/cfnlint/rules/resources/CreationPolicy.py index 84a922a33..67a2c9778 100644 --- a/src/cfnlint/rules/resources/CreationPolicy.py +++ b/src/cfnlint/rules/resources/CreationPolicy.py @@ -83,6 +83,10 @@ def validate(self, validator: Validator, dP: str, instance, schema): return resource_type = validator.context.resources[resource_name].type + # Fn::Select declares an all_types output, so the generic output-type + # check (see #4641) treats it as object-compatible. CloudFormation, + # however, rejects a bare Fn::Select here ("Expected an object") unless + # AWS::LanguageExtensions resolves it before deployment. See #4645. function, _ = is_function(instance) if ( function == "Fn::Select" diff --git a/src/cfnlint/rules/resources/updatepolicy/Configuration.py b/src/cfnlint/rules/resources/updatepolicy/Configuration.py index 2abd10eb4..2319d5a41 100644 --- a/src/cfnlint/rules/resources/updatepolicy/Configuration.py +++ b/src/cfnlint/rules/resources/updatepolicy/Configuration.py @@ -32,6 +32,10 @@ def __init__(self) -> None: ) def validate(self, validator: Validator, keywords: Any, instance: Any, schema: Any): + # Fn::Select declares an all_types output, so the generic output-type + # check (see #4641) treats it as object-compatible. CloudFormation, + # however, rejects a bare Fn::Select here ("Expected an object") unless + # AWS::LanguageExtensions resolves it before deployment. See #4645. update_policy = instance.get("UpdatePolicy") function, _ = is_function(update_policy) if ( @@ -44,15 +48,6 @@ def validate(self, validator: Validator, keywords: Any, instance: Any, schema: A rule=self, instance=update_policy, validator="type", - validator_value="object", - schema_path=[ - "allOf", - 0, - "then", - "properties", - "UpdatePolicy", - "type", - ], ) return diff --git a/test/unit/rules/resources/updatepolicy/test_configuration.py b/test/unit/rules/resources/updatepolicy/test_configuration.py index 9ae98157f..fcaab44be 100644 --- a/test/unit/rules/resources/updatepolicy/test_configuration.py +++ b/test/unit/rules/resources/updatepolicy/test_configuration.py @@ -66,15 +66,6 @@ def rule(): ] }, validator="type", - validator_value="object", - schema_path=[ - "allOf", - 0, - "then", - "properties", - "UpdatePolicy", - "type", - ], ) ], ),