Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
filol opened this issue Dec 5, 2021 · 8 comments
Labels
bug Something isn't working

Comments

@filol
Copy link

filol commented Dec 5, 2021

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
@filol filol added bug Something isn't working triage Pending triage from maintainers labels Dec 5, 2021
@boring-cyborg
Copy link

boring-cyborg bot commented Dec 5, 2021

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

@heitorlessa
Copy link
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!

@michaelbrewer
Copy link
Contributor

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

@michaelbrewer
Copy link
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.

@michaelbrewer
Copy link
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
  }
}

@filol
Copy link
Author

filol commented Dec 9, 2021

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

@filol
Copy link
Author

filol commented Dec 16, 2021

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

@heitorlessa heitorlessa added the pending-release Fix or implementation already in dev waiting to be released label Dec 20, 2021
@heitorlessa
Copy link
Contributor

Now released as part of 1.23 version

@heitorlessa heitorlessa removed triage Pending triage from maintainers pending-release Fix or implementation already in dev waiting to be released labels Dec 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants