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

Abierto
#8,714 1 comentario 0 reacciones 1 asignado Ver en GitHub

Los mantenedores suelen responder en 1 día

@anishmehta24 ya está trabajando en esto.

Desde el 30/10/2026.

  • #8715 de @anishmehta24 — abierto

Evaluación

Este issue todavía no se ha evaluado.

Descripción

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

Lenguaje dominante
Python
Estrellas
3.3k
Forks
511
Merge medio
3 d 8 h
PR fusionados (30 d)
92

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de aws-powertools/powertools-lambda-python

Todos los issues de aws-powertools/powertools-lambda-python

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.