Bug: AppSync identity from a Lambda authorizer (AWS_LAMBDA) is wrapped in AppSyncIdentityIAM
Maintainer thường phản hồi trong vòng 1 ngày
@Goldloli đang làm issue này rồi.
Từ ngày 31/10/2026.
Đánh giá
Issue này chưa được đánh giá.
Mô tả
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
- Ngôn ngữ chính
- Python
- Star
- 3.3k
- Fork
- 511
- Merge trung bình
- 3 ngày 8 giờ
- Pull request đã merge (30 ngày)
- 92
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của aws-powertools/powertools-lambda-python
-
Bug: POWERTOOLS_IDEMPOTENCY_DISABLED set to an empty or non-boolean value crashes every invocationCó thể đã có người làm @lechakrawarthy đã nhận 1 ngày trước. Đang mởbug good first issue help wanted idempotency
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
aws-powertools/powertools-lambda-python#8728 · 4 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Bug: Redis layer fails the invocation instead of retrying when a record expires between SET NX and GETCó thể đã có người làm @coughlmao đã nhận 1 ngày trước. Đang mởbug good first issue help wanted idempotency
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
aws-powertools/powertools-lambda-python#8727 · 4 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Bug: Redis orphan lock timeout ignores expires_after_seconds and is always 10 secondsCó thể đã có người làm @CJstate đã nhận 1 ngày trước. Đang mởbug good first issue help wanted idempotency
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
aws-powertools/powertools-lambda-python#8726 · 3 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Bug: idempotency payloads with set, frozenset or bytes fields cannot be hashedCó thể đã có người làm @Neeraj111010 đã nhận 1 ngày trước. Đang mởbug good first issue help wanted idempotency
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 80/100
aws-powertools/powertools-lambda-python#8725 · 4 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Bug: with a DynamoDB composite key, DataRecord.idempotency_key is the static partition key valueCó thể đã có người làm @sumedh-aerram đã nhận 1 ngày trước. Đang mởbug good first issue help wanted idempotency
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 90/100
aws-powertools/powertools-lambda-python#8724 · 3 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của aws-powertools/powertools-lambda-python
Issue tương tự
-
question
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
conda-forge/vc-feedstock#132 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
limitlessprojects/Go-Hybrid#3342 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
UKGovernmentBEIS/inspect_ai#6268 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
LSSTDESC/rail_sompz#42 ·
-
All tests fail with 'EXITED with status 3' on pytest 9.2.0 (TestReport._id is not marshallable)Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
pytest-dev/pytest-forked#113 ·