Skip to content

PreTokenGenerationTriggerEvent => claims_to_suppress : NoneType' object does not support item assignment #870

Closed

Description

@filol

What were you trying to accomplish?
I'm currently trying to add some claims to suppress to the token in the event object. Working with manual way (without your lib).

Expected Behavior

No exception

Current Behavior

Exception

Possible Solution

Steps to Reproduce (for bugs)

def handler(event, context):
    event: PreTokenGenerationTriggerEvent = PreTokenGenerationTriggerEvent(event)
    user_pool_id = event.user_pool_id
    claims_override_details = event.response.claims_override_details
    claims_override_details.claims_to_suppress = ["Email"]

Environment

  • Powertools version used: 1.22.0
  • Packaging format (Layers, PyPi):
  • AWS Lambda function runtime: Python 3.9
  • Debugging logs
    "exception": "Traceback (most recent call last):\n  File \"/var/task/main.py\", line 130, in handler\n    claims_override_details.claims_to_suppress = []\n  File \"/var/task/package/aws_lambda_powertools/utilities/data_classes/cognito_user_pool_event.py\", line 487, in claims_to_suppress\n    self._data[\"claimsToSuppress\"] = value\nTypeError: 'NoneType' object does not support item assignment"

How to enable debug mode**

2021-12-05 21:13:10,898 aws_lambda_powertools.logging.logger [DEBUG] Adding filter in root logger to suppress child logger records to bubble up
2021-12-05 21:13:10,898 aws_lambda_powertools.logging.logger [DEBUG] Marking logger service_undefined as preconfigured

Activity

  1. added
    bug
    triage
    on Dec 5, 2021
  2. boring-cyborg commented on Dec 5, 2021

    @boring-cyborg

    Thanks for opening your first issue here! We'll come back to you as soon as we can.

  3. heitorlessa commented on Dec 8, 2021

    @heitorlessa
    Contributor

    hey @filol thank you so much for filing this. Would you happen to have a copy of the event with any sensitive data redacted to help us reproduce/test it?

    cc @michaelbrewer

    Thank you!

  4. michaelbrewer commented on Dec 8, 2021

    @michaelbrewer
    Contributor

    I will have a look @filol and try to include it in our test coverage to be sure we don't regress.

  5. michaelbrewer commented on Dec 8, 2021

    @michaelbrewer
    Contributor

    @filol was claimsOverrideDetails in your event null? Would it be possible to post it with any values masked. I would be curious about the data structure.

  6. michaelbrewer commented on Dec 8, 2021

    @michaelbrewer
    Contributor

    @filol - i have PR (#878) that could fix this, if you could verify that the event did some from a real integration test and that is looks something like this:

    {
      "version": "1",
      "triggerSource": "TokenGeneration_Authentication",
      "region": "us-west-2",
      "userPoolId": "us-west-2_example",
      "userName": "testqq",
      "callerContext": {
        "awsSdkVersion": "aws-sdk-unknown-unknown",
        "clientId": "71ghuul37mresr7h373b704tua"
      },
      "request": {
        "userAttributes": {
          "sub": "0b0a57c5-f013-426a-81a1-f8ffbfba21f0",
          "email_verified": "true",
          "cognito:user_status": "CONFIRMED",
          "email": "test@mail.com"
        },
        "groupConfiguration": {
          "groupsToOverride": [],
          "iamRolesToOverride": [],
          "preferredRole": null
        }
      },
      "response": {
           "claimsOverrideDetails": null
      }
    }
  7. filol commented on Dec 9, 2021

    @filol
    Author

    Hi @michaelbrewer, I don't have the event right now on the hand. I will come back to you with my sample monday

  8. filol commented on Dec 16, 2021

    @filol
    Author

    @michaelbrewer There is my event from aws, so yes claimsOverrideDetails is null by default

    {
        "version": "1",
        "triggerSource": "TokenGeneration_RefreshTokens",
        "region": "eu-west-1",
        "userPoolId": "eu-west-1_xxxxxxxxx",
        "userName": "xxxxxxxxxx",
        "callerContext": {
            "awsSdkVersion": "aws-sdk-unknown-unknown",
            "clientId": "xxxxxxxxxxxxxxxxxxxxxxxxx"
        },
        "request": {
            "userAttributes": {
                "sub": "c7605922-xxxx-xxxx-a402-881ba30eeabc",
                "zoneinfo": "UTC",
                "cognito:email_alias": "xxxx",
                "cognito:user_status": "CONFIRMED",
                "email_verified": "true",
                "phone_number_verified": "false",
                "family_name": "xxxx",
                "email": "xxxx"
            },
            "groupConfiguration": {
                "groupsToOverride": [
                    "xxx",
                    "xxx",
                ],
                "iamRolesToOverride": [],
                "preferredRole": null
            }
        },
        "response": {
            "claimsOverrideDetails": null
        }
    }
    
  9. added
    pending-release
    on Dec 20, 2021
  10. heitorlessa commented on Dec 20, 2021

    @heitorlessa
    Contributor

    Now released as part of 1.23 version

  11. removed
    triage
    pending-release
    on Dec 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions