Skip to content

fix(E1011): skip FindInMap key errors when the key comes from a pseudo parameter - #5011

Merged
kddejong merged 2 commits into
aws-cloudformation:mainfrom
Varshith-Kali:fix-5010-findinmap-accountid-key
Nov 10, 2026
Merged

kddejong merged 2 commits into
aws-cloudformation:mainfrom
Varshith-Kali:fix-5010-findinmap-accountid-key

Conversation

@Varshith-Kali

Copy link
Copy Markdown
Contributor

Fixes #5010

A Fn::FindInMap top-level key built from a pseudo parameter, for example Fn::Sub '${AWS::AccountId}-${AWS::Region}', only resolves to lint-time placeholder values (AWS::AccountId is always 123456789012 at lint time), so it can never match the real deploy-time keys in the mapping. Since 1.60.0 (#4919) that produced false positives under the parent rules in unconstrained positions (E8003 in a condition, E1022 in Fn::Join, E6101 in an output) as well as E1011 in constrained positions.

Resolve the top-level key with pseudo parameters disabled, the same treatment the second-level key already gets in the same function, so such keys yield neither a value nor an error. Literal keys and keys resolved from parameters are unaffected, and hardcoded bad keys are still reported.

Tests: 9 new cases covering Sub (AccountId alone, AccountId with Region, Region alone) and Join key shapes at the resolver and rule levels, in both constrained and unconstrained paths, plus a control showing a literal Sub key is still reported. The new cases fail on the pre-fix tree and pass after.

…o parameter

Fixes aws-cloudformation#5010

A Fn::FindInMap top-level key built from a pseudo parameter, for
example Fn::Sub '${AWS::AccountId}-${AWS::Region}', only resolves
to lint-time placeholder values (AWS::AccountId is always
123456789012 at lint time), so it can never match the real
deploy-time keys in the mapping. Since 1.60.0 (aws-cloudformation#4919) that produced
false positives under the parent rules in unconstrained positions
(E8003 in a condition, E1022 in Fn::Join, E6101 in an output) as
well as E1011 in constrained positions.

Resolve the top-level key with pseudo parameters disabled, the same
treatment the second-level key already gets in the same function,
so such keys yield neither a value nor an error. Literal keys and
keys resolved from parameters are unaffected, and hardcoded bad
keys are still reported.

Tests: 9 new cases covering Sub (AccountId alone, AccountId with
Region, Region alone) and Join key shapes at the resolver and rule
levels, in both constrained and unconstrained paths, plus a control
showing a literal Sub key is still reported. The new cases fail on
the pre-fix tree and pass after.

Signed-off-by: Varshith Puli <pulivarshit@gmail.com>
@Varshith-Kali

Copy link
Copy Markdown
Contributor Author

Hi, this PR is ready for review. The CI run is waiting on first-time-contributor workflow approval, could a maintainer approve it when you get a chance? Thanks.

@codecov

codecov Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.81%. Comparing base (1d19193) to head (5975e9e).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5011   +/-   ##
=======================================
  Coverage   94.81%   94.81%           
=======================================
  Files         441      441           
  Lines       16188    16189    +1     
  Branches     3140     3140           
=======================================
+ Hits        15349    15350    +1     
  Misses        463      463           
  Partials      376      376           
Flag Coverage Δ
unittests 94.81% <100.00%> (+<0.01%) ⬆️

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 7d4034c into aws-cloudformation:main Nov 10, 2026
24 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.

E8003, E1022, E6101: false positive on Fn::FindInMap with AWS::AccountId in the key (regression in 1.60.0)

3 participants