Bug: AppSync identity from a Lambda authorizer (AWS_LAMBDA) is wrapped in AppSyncIdentityIAM
维护者通常 1 天内回复
评估
这个 Issue 还没有评估数据。
描述
Expected Behaviour
With AppSync AWS_LAMBDA authorization, the resolver event identity is what the authorizer returned in resolverContext, for example {"resolverContext": {"userId": "u-1", "tier": "gold"}}. AppSyncResolverEvent.identity should return a dedicated class exposing resolver_context, so the only field that exists in this mode is reachable through a typed property.
Current Behaviour
get_identity_object in aws_lambda_powertools/utilities/data_classes/appsync_resolver_event.py has two outcomes: an identity with sub becomes AppSyncIdentityCognito, anything else becomes AppSyncIdentityIAM. A Lambda-authorizer identity has neither sub nor IAM fields, so it lands on AppSyncIdentityIAM and every property on it (account_id, user_arn, source_ip, cognito_identity_*) raises KeyError. resolverContext is only reachable as a raw dict.
Code snippet
from aws_lambda_powertools.utilities.data_classes.appsync_resolver_event import get_identity_object
identity = get_identity_object({"resolverContext": {"userId": "u-1", "tier": "gold"}})
print(type(identity).__name__) # AppSyncIdentityIAM
identity.account_id # KeyError: 'accountId'
Possible Solution
- Add
AppSyncIdentityLambda(DictWrapper)with aresolver_contextproperty returning the dict the authorizer produced (see the AppSync docs on Lambda authorization: theidentityobject carriesresolverContext). - In
get_identity_object, dispatch on"resolverContext" in identitybefore the IAM fallback, and update the return type ofidentityand the docstring line that #8705 left marked as unverified. - Add a fixture with a Lambda-authorizer identity under
tests/events/, tests throughAppSyncResolverEvent(event).identity, and a line indocs/utilities/data_classes.md. - Keep the existing dispatch for
sub(Cognito and OIDC) and the IAM fallback unchanged.
This is a good first issue. Everything needed is in the file above plus the tests next to it; no AWS resources are required to reproduce.
Powertools for AWS Lambda (Python) version
latest
AWS Lambda function runtime
3.13
Packaging format used
PyPi
Debugging logs
No response
- 主要语言
- Python
- 星标
- 3.3k
- 派生
- 511
- 平均合并
- 3 天 8 小时
- 30 天内合并 PR
- 92
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
aws-powertools/powertools-lambda-python 的其他 Issue
-
Bug: POWERTOOLS_IDEMPOTENCY_DISABLED set to an empty or non-boolean value crashes every invocation可能已有人在做 @lechakrawarthy 于 2 天前认领。 未关闭bug good first issue help wanted idempotency
难度 2/5 1-3 小时 新手友好度 85/100
aws-powertools/powertools-lambda-python#8728 · 4 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
Bug: Redis layer fails the invocation instead of retrying when a record expires between SET NX and GET可能已有人在做 @coughlmao 于 2 天前认领。 未关闭bug good first issue help wanted idempotency
难度 2/5 1-3 小时 新手友好度 85/100
aws-powertools/powertools-lambda-python#8727 · 4 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
Bug: Redis orphan lock timeout ignores expires_after_seconds and is always 10 seconds可能已有人在做 @CJstate 于 2 天前认领。 未关闭bug good first issue help wanted idempotency
难度 2/5 1-3 小时 新手友好度 75/100
aws-powertools/powertools-lambda-python#8726 · 3 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
Bug: idempotency payloads with set, frozenset or bytes fields cannot be hashed可能已有人在做 @Neeraj111010 于 2 天前认领。 未关闭bug good first issue help wanted idempotency
难度 2/5 1-3 小时 新手友好度 80/100
aws-powertools/powertools-lambda-python#8725 · 6 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
Bug: with a DynamoDB composite key, DataRecord.idempotency_key is the static partition key value可能已有人在做 @sumedh-aerram 于 2 天前认领。 未关闭bug good first issue help wanted idempotency
难度 2/5 1-3 小时 新手友好度 90/100
aws-powertools/powertools-lambda-python#8724 · 3 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
查看 aws-powertools/powertools-lambda-python 的全部 Issue
相似的 Issue
-
难度 1/5 1 小时以内 新手友好度 78/100
521xueweihan/HelloGitHub#4237 ·
-
bug
难度 2/5 1-3 小时 新手友好度 78/100
jejjohnson/gaussx#721 ·
维护者通常 1 天内回复
-
mock-core-configs/etc/mock/rocky-10-riscv64.cfg contains the wrong architecture in config_opts['root']可能已有人在做 @jasonmontleon 于 4 天前认领。 未关闭
难度 1/5 1 小时以内 新手友好度 94/100
rpm-software-management/mock#1834 ·
-
难度 1/5 1 小时以内 新手友好度 75/100
elastic/elastic-otel-python#683 ·
维护者通常 1 天内回复
-
ci-rerun: collect.py fails a whole pr-babysit cycle on one transient GitHub 5xx and never retries未关闭follow-up
难度 2/5 1-3 小时 新手友好度 62/100
维护者通常 1 天内回复