Skip to content

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

Closed

Description

@anishmehta24

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

Activity

  1. leandrodamascena commented on Oct 30, 2026

    @leandrodamascena
    Contributor

    Thanks @anishmehta24, confirmed. Transfer Family leaves password out for key-based logins and we blow up with KeyError instead of returning None like the type hint says. I'll review #8715. Goes into 3.40.0.

  2. added this to the 3.40.0 milestone on Oct 30, 2026
  3. leandrodamascena commented on Nov 4, 2026

    @leandrodamascena
    Contributor

    Fixed by #8715, merged as c8da226.

  4. powertools-for-aws-oss-automation commented on Nov 4, 2026

    @powertools-for-aws-oss-automation

    Warning

    This issue is now closed. Please be mindful that future comments are hard for our team to see.
    If you need more assistance, please either reopen the issue, or open a new issue referencing this one.
    If you wish to keep having a conversation with other community members under this issue feel free to do so.

  5. github-actions commented on Nov 10, 2026

    @github-actions
    Contributor

    This is now released under 3.40.0 version!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingevent_sourcesEvent Source Data Class utility

Type

No type

Projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions