fix(WS2001): handle intrinsic functions in AccessLogSetting.Format#254
Open
abhu85 wants to merge 1 commit intoawslabs:mainfrom
Open
fix(WS2001): handle intrinsic functions in AccessLogSetting.Format#254abhu85 wants to merge 1 commit intoawslabs:mainfrom
abhu85 wants to merge 1 commit intoawslabs:mainfrom
Conversation
When AccessLogSetting.Format or AccessLogSettings.Format is set to an intrinsic function like !Ref or !Sub, the _check_log_format method would crash with "'dict_node' object has no attribute 'strip'" because it expected a string but received a dict-like node. This fix adds a type check at the start of _check_log_format to skip validation when the format is not a string (i.e., when it's an intrinsic function). This prevents the crash and allows templates with parameterized log formats to pass linting. Fixes awslabs#253 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Author
|
Friendly ping for review when you have a chance. This fixes the crash reported in #253 when using intrinsic functions like |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #253
When
AccessLogSetting.Format(REST APIs) orAccessLogSettings.Format(HTTP APIs) is set to an intrinsic function like!Refor!Sub, the WS2001 rule crashes with:Root cause: The
_check_log_formatmethod inapi_gateway.pycalls.strip()on line 78 without checking if the input is a string. When CloudFormation intrinsic functions are used, the value is a dict-like node (e.g.,{"Ref": "LogFormat"}), not a string.Fix: Added a type check at the start of
_check_log_formatto skip validation when the format is not a string (i.e., when it's an intrinsic function). This prevents the crash and allows templates with parameterized log formats to pass linting.Changes
isinstance(log_format, str)check in_check_log_formatmethod!Ref) and HTTP APIs (!Sub)Test Plan
ws2001-rest-ref-format.pass.yaml- Tests!Refwith REST APIws2001-http-sub-format.pass.yaml- Tests!Subwith HTTP APImake prpasses (linting, security, complexity checks)Commands run:
Generated with Claude Code