fix Globals.Function Architectures override behavior#3940
Open
allenheltondev wants to merge 1 commit into
Open
fix Globals.Function Architectures override behavior#3940allenheltondev wants to merge 1 commit into
allenheltondev wants to merge 1 commit into
Conversation
Signed-off-by: Allen Helton <allenheltondev@gmail.com>
reedham-aws
reviewed
Jun 11, 2026
reedham-aws
left a comment
Contributor
There was a problem hiding this comment.
Thank you for raising this!
Seems like the linter is failing as well, you can fix locally with make format or make lint.
Comment on lines
+457
to
+468
| global_properties = self._drop_overridden_globals(self.global_properties, local_properties) | ||
| return self._do_merge(global_properties, local_properties) # type: ignore[no-untyped-call] | ||
|
|
||
| def _drop_overridden_globals(self, global_properties, local_properties): # type: ignore[no-untyped-def] | ||
| if not self.override_properties or not isinstance(global_properties, dict) or not isinstance(local_properties, dict): | ||
| return global_properties | ||
|
|
||
| global_properties = global_properties.copy() | ||
| for key in self.override_properties: | ||
| if key in global_properties and key in local_properties: | ||
| del global_properties[key] | ||
| return global_properties |
Contributor
There was a problem hiding this comment.
I think this approach makes sense and would work, but I my first instinct is that we could get rid of the loop/copy by checking the override_properties in _merge_dict. I left another comment in the place where that might work, but I could be missing something, let me know what you think.
| global_dict = global_dict.copy() | ||
|
|
||
| for key in local_dict: | ||
| if key in global_dict: |
Contributor
There was a problem hiding this comment.
I think we could have a condition here to see if the key is in the overrides, and if it's not then we could enter the else. I think this would accomplish the same thing.
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.
Issue #, if available
Fixes #3939
Description of changes
Updates
Globals.Functionmerge behavior so resource-levelArchitecturesoverrides globalArchitecturesinstead of concatenating both lists.Architecturesis list-shaped, but Lambda functions support a single architecture value. This keeps the existing default list merge behavior for other properties, such asLayers, while handlingArchitectureslike other overridable function properties.Description of how you validated changes
Ran:
Result: 48 passed.
Also updated the globals_for_function translator fixture to cover resource-level Architectures overriding Globals.Function.Architectures across standard, aws-cn, and aws-us-gov outputs.
Integration tests were not added because this change is limited to Globals merge behavior and is covered by unit tests plus translator output fixtures.
Checklist
Examples?
Please reach out in the comments if you want to add an example. Examples will be
added to
sam initthrough aws/aws-sam-cli-app-templates.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.