Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

SDK publishes exception segment regardless whether it's handled or not

Abierto
#274 5 comentarios 1 reacción 1 asignado Ver en GitHub

@wangzlei ya está trabajando en esto.

Desde el 22/3/2021.

Evaluación

Este issue todavía no se ha evaluado.

Descripción

This was originally brought up in https://github.com/awslabs/aws-lambda-powertools-python/issues/334 but @heitorlessa mentioned this is could be an upstream issue here and asked me to file an Issue. The details can be found in the original issue as well but we have the following function in our lambda code:

def get_secrets(secret_name) -> dict:
    try:
        get_secret_value_response = client.get_secret_value(SecretId=secret_name)
    except ClientError as e:
        if e.response["Error"]["Code"] == "ResourceNotFoundException":
            if "AWSCURRENT" in e.response["Message"]:
                logger.warning(f"{secret_name} exists but is empty.")
            else:
                logger.warning(
                    f"The requested secret {secret_name} was not found. Create the secret first."
                )
            return {}
        else:
            raise RuntimeError("Couldn't retrieve secrets")
    else:
        return json.loads(get_secret_value_response["SecretString"])

And in our case we continue processing if the secret exists but a value hasn't been set. In this case we're catching and handling the exception, continuing execution. However, the SDK will still flag this as an exception in X-Ray which will show the service as erroring when it actually isn't.

The relevant line is at https://github.com/aws/aws-xray-sdk-python/blob/508f929fee495710656c0c1478f8873a2e9e5666/aws_xray_sdk/core/models/subsegment.py#L70-L78

Is there a way to handle this use case?

Lenguaje dominante
Python
Estrellas
340
Forks
148
Métricas de merge de PR
Sin PR fusionados en 30 d

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/aws-xray-sdk-python

Todos los issues de aws/aws-xray-sdk-python

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.