Skip to content

Bug: UnauthorizedException raises TypeError when using documented keyword arguments #7693

@T90REAL

Description

@T90REAL

Expected Behaviour

The public docs for AppSync exceptions state that UnauthorizedException accepts optional keyword arguments.

Current Behaviour

The implementation forwards those kwargs directly to Exception.__init__, which doesn’t accept keyword arguments, so any caller passing a documented kwarg receives TypeError.

Code snippet

from aws_lambda_powertools.event_handler.events_appsync.exceptions import UnauthorizedException

UnauthorizedException("Access denied", trace_id="abc123")
Traceback (most recent call last):
  File "/data/src/test.py", line 4, in <module>
    UnauthorizedException("Access denied", trace_id="abc123")
  File "/home/hdd/miniconda3/envs/py312/lib/python3.12/site-packages/aws_lambda_powertools/event_handler/events_appsync/exceptions.py", line 24, in __init__
    super().__init__(message, *args, **kwargs)
TypeError: UnauthorizedException() takes no keyword arguments

Possible Solution

Fix could be either consume/record kwargs inside UnauthorizedException before calling super().__init__, or remove **kwargs from the signature/docs to reflect the real capability.

Steps to Reproduce

Run the repro script.

Powertools for AWS Lambda (Python) version

latest

AWS Lambda function runtime

3.12

Packaging format used

PyPi

Debugging logs

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingpending-releaseFix or implementation already in dev waiting to be released

Type

Projects

Status

Coming soon

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions