You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: share Fn::ForEach and SAM-mapping helpers across modules
Two issues flagged by the bot reviewer on PR #8637:
[BUG] _update_sam_mappings_relative_paths in samcli/commands/_utils/
template.py used mapping_name.startswith("SAM") to decide whether to
rewrite Mapping values as relative paths. That loose check corrupts
customer-authored mappings whose names happen to start with SAM as a
substring — SAMPLE, SAMSUNG, SAMCustomMapping, etc. Values would be
silently rewritten with relative-path prefixes.
[STYLE] infra_sync_executor.py had two hardcoded
resource_logical_id.startswith("Fn::ForEach::") checks instead of
using the shared is_foreach_key helper the rest of the codebase
adopted in this PR. Maintenance risk if the detection logic ever
changes.
Consolidation:
- Moved the precise SAM-mapping classifier (previously
_is_sam_generated_mapping in samcli/commands/deploy/exceptions.py)
into samcli/lib/cfn_language_extensions/utils.py as the public
is_sam_generated_mapping so both deploy/exceptions.py and
commands/_utils/template.py share the same implementation.
- _update_sam_mappings_relative_paths now calls
is_sam_generated_mapping — SAMPLE/SAMSUNG style names are
correctly ignored.
- infra_sync_executor.py now calls is_foreach_key at both sites.
Tests:
- test_skips_sam_prefix_substring_mappings in
TestUpdateSamMappingsRelativePaths verifies SAMPLE/SAMSUNG/
SAMCustomMapping are left untouched.
- Existing TestIsSamGeneratedMapping and TestCreateDeployError
still pass via the re-export in deploy/exceptions.py.
0 commit comments