Skip to content

Allow Fn::If and nested Fn::Select as the Fn::Select index - #4793

Merged
kddejong merged 1 commit into
aws-cloudformation:mainfrom
Varshith-Kali:fix-4776-select-index-fns
Oct 21, 2026
Merged

kddejong merged 1 commit into
aws-cloudformation:mainfrom
Varshith-Kali:fix-4776-select-index-fns

Conversation

@Varshith-Kali

Copy link
Copy Markdown
Contributor

Fixes #4776

The Fn::Select index slot (prefixItems[0]) in select.json whitelisted only Ref and Fn::FindInMap (plus Fn::Length under AWS::LanguageExtensions), so E1017 reported Fn::If or a nested Fn::Select in the index position as "is not of type 'integer'". CloudFormation accepts both shapes: they resolve to an integer at deploy time, and stacks using them reach CREATE_COMPLETE.

This change adds Fn::If and Fn::Select to the index cfnContext.functions lists in both the then and else branches of the schema.

Verification:

  • Reproduced the exact E1017 from the issue against the current schema ({'Fn::If': ['IsSet', '1', '0']} is not of type 'integer'), confirmed it is gone after the change.
  • Added regression tests for both new index functions in test_select.py (else branch) and test_select_language_extension.py (then branch): they fail before the fix and pass after.
  • Full rules suite: 1946 passed. Ruff check and format clean.

The index position (prefixItems[0]) in select.json only whitelisted Ref
and Fn::FindInMap (plus Fn::Length under AWS::LanguageExtensions), so
E1017 reported Fn::If or a nested Fn::Select in the index slot as
"is not of type 'integer'". CloudFormation accepts both: they resolve
to an integer at deploy time. Add Fn::If and Fn::Select to the index
function lists in both the then and else branches, and add regression
tests covering each branch.

Fixes aws-cloudformation#4776

Signed-off-by: Varshith Puli <pulivarshit@gmail.com>
@kddejong
kddejong force-pushed the fix-4776-select-index-fns branch from 326805b to ba2b6a9 Compare October 21, 2026 17:02
@codecov

codecov Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.72%. Comparing base (27243cb) to head (ba2b6a9).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4793   +/-   ##
=======================================
  Coverage   94.72%   94.72%           
=======================================
  Files         439      439           
  Lines       15908    15908           
  Branches     3079     3079           
=======================================
  Hits        15069    15069           
  Misses        458      458           
  Partials      381      381           
Flag Coverage Δ
unittests 94.72% <ø> (ø)

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 2dfd19f into aws-cloudformation:main Oct 21, 2026
22 checks passed
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.

E1017: Fn::If and nested Fn::Select as the Fn::Select index reported as "is not of type 'integer'"

2 participants