Skip to content

fix(E2011, E7002): report I2011 and I7002 for names near the limit - #4965

Merged
kddejong merged 1 commit into
aws-cloudformation:mainfrom
hoganbr-amzn:fix/i2011-i7002-property-names
Oct 30, 2026
Merged

kddejong merged 1 commit into
aws-cloudformation:mainfrom
hoganbr-amzn:fix/i2011-i7002-property-names

Conversation

@hoganbr-amzn

Copy link
Copy Markdown
Contributor

Issue #, if available: Fixes #4960

Description of changes:

I2011 (Parameter name approaching the limit) and I7002 (Mapping name approaching the limit) never reported. E2011 and E7002 extend jsonschema.PropertyNames, which reports the approaching-limit child only from _max_length. That helper is installed inside its propertyNames keyword handler. E2001 (rules/parameters/Configuration.py) and E7001 (rules/mappings/Configuration.py) mapped only maxLength to E2011 and E7002, so the handler never ran for these sections.

This change adds "propertyNames": "E2011" and "propertyNames": "E7002" to the two rule_set maps. Outputs ("propertyNames": "E6011") and Resources ("propertyNames": "E3011") are already wired this way, which is why I6011 and I3012 report today. The Mappings entry was dropped in #3257.

Name Length Before After
Parameter 230 to 255 nothing I2011
Parameter 256 E2011 expected maximum length: 255, found: 256 E2011 '<name>' is longer than 255
Mapping, or Mapping attribute 230 to 255 nothing I7002
Mapping, or Mapping attribute 256 E7002 expected maximum length: 255, found: 256 E7002 '<name>' is longer than 255
Any of the above 229 or less nothing nothing

The new over-limit message is the one E6011 and E3011 already use. No snapshot under test/fixtures/results/ or entry in docs/rules.md references the old text.

E2001 still reports an unknown Parameter attribute, such as Foo, because the error keeps propertyNames and enum in its schema path. A test case pins this.

Evidence. The CloudFormation quotas page lists 255 characters for a parameter name and for a mapping name and mapping attribute name. CloudFormation stack in us-east-1, in a personal AWS account, on 2026-10-22: the template in #4960 reached CREATE_COMPLETE with 240-character Parameter, Mapping, Resource and Output names. So names in the I2011 and I7002 range deploy, and the change adds informational findings only.

Tests. The new tests are test/unit/rules/parameters/test_property_names.py and test/unit/rules/mappings/test_max_length.py. They run a full cfnlint.api.lint rather than the single-rule validator fixture, because the bug is in how E2001 and E7001 wire in their child rules, and the fixture loads no child rules. They assert the rule id and exact message at 229, 230, 255 and 256 characters, for Parameter names, Mapping names and Mapping attribute names. On main, 10 of the 17 cases fail.

Verification, on this branch and on main (008ead6), with specs from cfn-lint --update-specs:

  • cfn-lint --regions us-east-1 -c I -- template.yaml on the I2011, I7002: Parameter and Mapping names approaching the 255-character limit are never reported #4960 template: main reports I3012 and I6011; this branch also reports I2011 and I7002.
  • python -m pytest test: 3269 passed on main, 3286 passed on this branch, no failures on either.
  • cfn-lint -c I -f parseable -t "test/fixtures/templates/good/**/*.yaml" "test/fixtures/templates/good/**/*.json": identical output on both apart from log timestamps and paths, with no E2011, I2011, E7002 or I7002 on any good fixture.
  • pre-commit run --all-files: passes.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@hoganbr-amzn
hoganbr-amzn marked this pull request as ready for review October 30, 2026 19:34
The approaching-limit child of E2011 and E7002 is only reported from
the propertyNames handler in the shared PropertyNames rule. E2001 and
E7001 mapped maxLength but not propertyNames to these rules, so the
handler never ran for Parameters and Mappings. Map propertyNames the
same way Outputs and Resources do.

Names over 255 characters now report "'<name>' is longer than 255",
the message E6011 and E3011 already use.

Fixes aws-cloudformation#4960

Signed-off-by: Brenden Hogan <hoganbr@amazon.com>
@kddejong
kddejong force-pushed the fix/i2011-i7002-property-names branch from a0edf6f to 12b9b76 Compare October 30, 2026 23:01
@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 (a694a33) to head (12b9b76).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4965   +/-   ##
=======================================
  Coverage   94.73%   94.73%           
=======================================
  Files         442      442           
  Lines       16102    16102           
  Branches     3125     3125           
=======================================
  Hits        15255    15255           
  Misses        467      467           
  Partials      380      380           
Flag Coverage Δ
unittests 94.73% <ø> (ø)

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 f1ad649 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.

I2011, I7002: Parameter and Mapping names approaching the 255-character limit are never reported

2 participants