Skip to content

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

Closed

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

Note: This issue was identified by an automated testing tool for academic research and manually verified. If you have any concerns about this type of reporting, please let me know, and I will adjust my workflow accordingly.

Activity

  1. added
    bug
    triage
    on Nov 15, 2025
  2. leandrodamascena commented on Nov 15, 2025

    @leandrodamascena
    Contributor

    Hi! Yes, I think we need to remove **kwargs from the signature to avoid confusing customers, as we don't accept it. Also, the UnauthorizedException exception is only used to return messages to AppSync, not additional arguments.

    Could you submit a PR to fix this?

  3. removed
    triage
    on Nov 15, 2025
  4. T90REAL commented on Nov 17, 2025

    @T90REAL
    ContributorAuthor

    Could you submit a PR to fix this?

    Sure. I will submit a PR for this.

  5. moved this from Backlog to Pending review in Powertools for AWS Lambda (Python)on Nov 17, 2025
  6. powertools-for-aws-oss-automation commented on Nov 17, 2025

    @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.

  7. added
    pending-release
    on Nov 17, 2025
  8. github-actions commented on Jan 5, 2026

    @github-actions
    Contributor

    This is now released under 3.24.0 version!

  9. removed
    pending-release
    on Jan 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions