Skip to content

fix(E1011): skip FindInMap key errors when map name comes from a parameter Default - #4810

Merged
kddejong merged 1 commit into
aws-cloudformation:mainfrom
Varshith-Kali:fix/e1011-map-name-from-parameter-default-4802
Oct 30, 2026
Merged

kddejong merged 1 commit into
aws-cloudformation:mainfrom
Varshith-Kali:fix/e1011-map-name-from-parameter-default-4802

Conversation

@Varshith-Kali

Copy link
Copy Markdown
Contributor

fixes #4802

Problem

Since v1.53.1 (#4580), a Fn::FindInMap lookup that fails only because a key came from a parameter's Default is not reported, because the deployer can override the Default at deployment time. The same lookup was still reported when the value taken from the Default was the map name (the first argument).

Repro (from #4802) reported two spurious E1011 findings:

E1011 'TopicSuffix' is not one of ['Other'] for mapping 'beta' and key 'us-east-1'
E1011 'TopicSuffix' is not a second level key when {'Ref': 'AWS::Region'} is resolved for mapping 'beta'

while the equivalent #4580 shape (TopKeyFromDefault) stayed silent.

Root cause

In find_in_map (src/cfnlint/jsonschema/_resolvers_cfn.py), the map name is resolved via validator.resolve_value(instance[0]), which yields a validator (map_v) carrying the is_resolved_from_parameters flag when the map name comes from a parameter's Default. However, the key errors for that map name were yielded with the outer key validators (top_v, second_v, or the plain outer validator in the Ref: AWS::Region branch), which do not carry the flag. The #4580 skip in BaseFn.resolve checks the flag on the validator yielded with the error, so it never fired for the map-name-from-Default shape.

Fix

Added a small per-map-name helper inside find_in_map that carries the resolved-from-parameters flag onto the validators yielded with key errors (both the literal-key branch and the Ref pseudo-parameter branch) whenever the map name resolved from parameters. The map-name-not-found error already used map_v, so it needed no change, and hardcoded map names keep their existing behavior (missing keys still reported).

Testing

  • Reproduced both E1011 findings from E1011: Fn::FindInMap reported when only the map name comes from a parameter Default #4802 on the unmodified tree; after the fix, all three resources in the repro template are silent (cfn-lint --regions us-east-1 exits 0).
  • Verified hardcoded map names still report: missing second-level key, Ref: AWS::Region top key, unknown map name, all still fire; a valid lookup stays silent.
  • Added test_resolve_map_name_from_parameter_default (7 cases) to test/unit/rules/functions/test_find_in_map.py: the 3 parameter-Default map-name cases fail on the pre-fix tree and pass after; the 4 hardcoded-map-name cases pass on both.
  • Full test/unit/rules suite: 1949 passed. test/unit/module: 988 passed; 6 failures plus one collection error are pre-existing on the base commit and unrelated (config CLI args, pricing specs, getatts, formatters).
  • ruff check and ruff format --check clean on both changed files.

@Varshith-Kali

Copy link
Copy Markdown
Contributor Author

Hi, the [CI] Test PR run on this PR is parked waiting for a maintainer approval (first-time-contributor gate). Could someone approve it when you get a chance? Thanks.

@Varshith-Kali

Copy link
Copy Markdown
Contributor Author

Hi @kddejong, the [CI] Test PR run on this PR is parked waiting for a maintainer approval (first-time-contributor gate). Could someone approve it when you get a chance? Thanks.

@Varshith-Kali

Copy link
Copy Markdown
Contributor Author

Hi team, the [CI] Test PR workflow run on the current head is still parked waiting for a first-time-contributor approval (action_required). Could a maintainer approve the run so CI can proceed? Thanks.

@Varshith-Kali

Copy link
Copy Markdown
Contributor Author

Hi @kddejong, friendly follow up: the CI runs on this PR are still parked at the first-time-contributor approval gate (action_required), so the checks cannot start until a maintainer approves the run. Could you approve it when you have a moment? Thanks!

@kddejong
kddejong force-pushed the fix/e1011-map-name-from-parameter-default-4802 branch from cabb979 to c8ff0c6 Compare October 29, 2026 18:40
…meter Default

Since v1.53.1 (aws-cloudformation#4580), a Fn::FindInMap lookup that fails only because a key
came from a parameter's Default is not reported, because the deployer can
override the Default. The same lookup was still reported when the value taken
from the Default was the map name: find_in_map resolved the map name on a
validator carrying the resolved-from-parameters flag but yielded the key
errors from the outer validator, so the aws-cloudformation#4580 skip in BaseFn.resolve never
saw the flag.

Carry the flag onto the validators yielded with key errors when the map name
resolved from parameters. Hardcoded map names are unaffected and still
validate.

Signed-off-by: Varshith Puli <pulivarshit@gmail.com>
@kddejong
kddejong force-pushed the fix/e1011-map-name-from-parameter-default-4802 branch from c8ff0c6 to 865dce0 Compare October 30, 2026 21:47
@codecov

codecov Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.73%. Comparing base (b3bc127) to head (865dce0).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4810   +/-   ##
=======================================
  Coverage   94.73%   94.73%           
=======================================
  Files         442      442           
  Lines       16088    16092    +4     
  Branches     3121     3122    +1     
=======================================
+ Hits        15241    15245    +4     
  Misses        467      467           
  Partials      380      380           
Flag Coverage Δ
unittests 94.73% <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 6a1aad5 into aws-cloudformation:main Oct 30, 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.

E1011: Fn::FindInMap reported when only the map name comes from a parameter Default

2 participants