Bug: TransferFamilyAuthorizer.password raises KeyError when the event has no password

未关闭
#8,714 1 条评论 0 个 reaction 已指派 1 人 在 GitHub 查看

维护者通常 1 天内回复

@anishmehta24 已经在做这个了。

开始于 2026年10月30日。

  • #8715 来自 @anishmehta24 —— 未关闭

评估

这个 Issue 还没有评估数据。

描述

bug event_sources

Expected Behaviour

TransferFamilyAuthorizer.password is typed str | None and documented as "None in case customer authenticating with certificates", so an authorizer event without a password should give None. The Pydantic TransferFamilyAuthorizer model already declares password with default=None.

Current Behaviour

The property returns self["password"], so an event without a password key raises KeyError instead of returning None. The custom identity provider examples in the Transfer Family docs read it defensively (event.get('password', '') == '' in Python) to detect key-based logins, which the data class can't do today.

Code snippet

from aws_lambda_powertools.utilities.data_classes import TransferFamilyAuthorizer

event = {"username": "bobusa", "protocol": "SFTP", "serverId": "s-abcd123456", "sourceIp": "192.168.0.100"}
TransferFamilyAuthorizer(event).password  # KeyError: 'password'

Steps to Reproduce

  1. Build a TransferFamilyAuthorizer from an event that has no password key.
  2. Read .password.
  3. KeyError is raised.

Possible Solution

Return self.get("password"), matching the type hint and the Pydantic model. I can open a PR.

Powertools for AWS Lambda (Python) version

latest (develop, 3.38.0)

AWS Lambda function runtime

3.12

Packaging format used

PyPi

Debugging logs

No response

主要语言
Python
星标
3.3k
派生
511
平均合并
3 天 8 小时
30 天内合并 PR
92

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

aws-powertools/powertools-lambda-python 的其他 Issue

查看 aws-powertools/powertools-lambda-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。