Implicit API: local PropagateTags: false is silently overridden by global PropagateTags: true
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 72/100
Research direction
The behavior is in ImplicitApiPlugin._add_tags_to_implicit_api_if_necessary(); read that entry point and compare its local/global selection with GlobalProperties._prefer_local in samtranslator/plugins/globals/globals.py. Done means an explicit false prevents tags from reaching generated implicit AWS::Serverless::Api or HttpApi resources, while an unset value still follows the global setting.
Written by the indexing model from the issue text.
Description
Describe the bug
ImplicitApiPlugin._add_tags_to_implicit_api_if_necessary() decides whether to copy a resource's Tags onto its generated implicit AWS::Serverless::Api/HttpApi resource using:
should_propagate_tags = resource.properties.get("PropagateTags") or globals_var.get("PropagateTags")
PropagateTags is documented as bool | None (see samtranslator/internal/schema_source/aws_serverless_function.py), where None means "not set" and False is a meaningful, explicit opt-out. Using or means a local PropagateTags: false is indistinguishable from "not set" — it silently falls through to the global value.
Reproduction
Globals:
Function:
PropagateTags: true
Tags:
Team: Data
Resources:
MyFunction:
Type: AWS::Serverless::Function
Properties:
PropagateTags: false # explicit opt-out
Runtime: python3.12
Handler: index.handler
CodeUri: s3://bucket/key
Events:
Api:
Type: Api
Properties:
Path: /hello
Method: get
Expected behavior
The function explicitly disables PropagateTags, so the generated implicit AWS::Serverless::Api should NOT receive the Team: Data tag.
Actual behavior
resource.properties.get("PropagateTags") returns False (falsy), so or evaluates the global value (True) instead, and the tag is propagated to the implicit API anyway — silently ignoring the resource-level override.
This is inconsistent with the standard Globals merge logic (GlobalProperties._prefer_local in samtranslator/plugins/globals/globals.py), which always prefers the local value when the key is present locally, regardless of its truthiness.
Fix
PR incoming.
- Dominant language
- Python
- Stars
- 9.6k
- Forks
- 2.5k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 7
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from aws/serverless-application-model
-
HttpApi: explicit AuthorizationScopes: [] is silently overridden by the authorizer's default scopes Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
aws/serverless-application-model#3979 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
aws/serverless-application-model#3973 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
aws/serverless-application-model#3995 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 55/100
aws/serverless-application-model#3970 ·
-
contributors/welcome type/feature
Difficulty 4/5 3-5 days Newbie friendliness 55/100
aws/serverless-application-model#3925 · 5 comments ·
All issues in aws/serverless-application-model
Similar issues
-
documentation help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
simonw/sqlite-utils#872 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100