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

オープン
#8,714 コメント 1 件 リアクション 0 件 担当者 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時間
マージ済み PR(30日)
92

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

aws-powertools/powertools-lambda-python のほかの issue

aws-powertools/powertools-lambda-python の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。