Bug: `log_uncaught_exceptions` only works locally and not on lambda

Đang mở
#1,798 23 bình luận 5 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 2 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
52/100
Loại issue
Tài liệu
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
aws, python

Hướng nghiên cứu

Start by locating the documentation for Logger(log_uncaught_exceptions=True) and reviewing the discussion about why the behavior differs in AWS Lambda. Reproduce the provided handler in an actual Lambda runtime and compare its output with local execution. The change is complete when the documentation clearly states which environments support this option and explains the observed unstructured output; confirm the project’s documentation build or relevant checks if available.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

bug-upstream logger revisit-in-3-months
Expected Behaviour

When log_uncaught_exceptions=True, uncaught exceptions in a lambda are handled and transformed to a structured log.

Current Behaviour

Uncaught exceptions are printed unstructured.

Code snippet
from aws_lambda_powertools import Logger
from aws_lambda_powertools.utilities.typing import LambdaContext

logger = Logger(log_uncaught_exceptions=True)

def lambda_handler(event: dict, context: LambdaContext) -> str:
    raise(Exception("asdf"))
Possible Solution

Probably none. Document this behavior.

I don't think sys.excepthook can be overridden in a lambda container, but I have no proof because the original forum thread that details this has been deleted by AWS with no replacement.

Steps to Reproduce

Set log_uncaught_exceptions=True in an actual running lambda. If log_uncaught_exceptions=True on a local machine, the behavior runs just as intended.

AWS Lambda Powertools for Python version

latest

AWS Lambda function runtime

3.9

Packaging format used

Lambda Layers

Debugging logs

No response

Ngôn ngữ chính
Python
Star
3.3k
Fork
511
Merge trung bình
3 ngày 12 giờ
Pull request đã merge (30 ngày)
93

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của aws-powertools/powertools-lambda-python

Tất cả issue của aws-powertools/powertools-lambda-python

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.