Skip to content

Fix E3031 false positive for boolean values with pattern#4485

Merged
kddejong merged 1 commit into
aws-cloudformation:mainfrom
kddejong:fix/issue/4484
Apr 28, 2026
Merged

Fix E3031 false positive for boolean values with pattern#4485
kddejong merged 1 commit into
aws-cloudformation:mainfrom
kddejong:fix/issue/4484

Conversation

@kddejong
Copy link
Copy Markdown
Contributor

Summary

Fix incorrect E3031 error reported for boolean properties that have a pattern keyword in the schema (e.g., SES ConfigurationSet's ReputationMetricsEnabled and SendingEnabled).

Root Cause

The pattern function in _keywords.py used str(instance) to convert non-string values before regex matching. Python's str(True) produces "True", but CloudFormation stringifies booleans as lowercase "true". The upstream SES ConfigurationSet schema defines these properties as type: boolean with pattern: "true|false", so "True" didn't match.

Fix

Changed str(instance) to json.dumps(instance) which produces "true"/"false" for booleans — matching CloudFormation's actual behavior.

Testing

  • Verified against real CloudFormation deployments that boolean true is the correct type
  • Added unit test for boolean pattern matching
  • Updated existing test to reflect correct stringification
  • All 354 existing tests pass

Fixes #4484

Use json.dumps() instead of str() when converting non-string values
for pattern matching. This correctly converts True to 'true' (matching
CloudFormation behavior) instead of Python's 'True'.

Fixes aws-cloudformation#4484
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.47%. Comparing base (79871e2) to head (37f3003).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4485   +/-   ##
=======================================
  Coverage   93.47%   93.47%           
=======================================
  Files         459      459           
  Lines       15022    15023    +1     
  Branches     2906     2906           
=======================================
+ Hits        14042    14043    +1     
  Misses        601      601           
  Partials      379      379           
Flag Coverage Δ
unittests 93.47% <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 Sentry.
📢 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 49dd9c5 into aws-cloudformation:main Apr 28, 2026
18 checks passed
@kddejong kddejong deleted the fix/issue/4484 branch April 28, 2026 16:37
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.

Incorrect E3031 error reported for SES configuration set

1 participant