Unable to push because of "Invalid AttributeDataType input" in auth with all attributes in sync to cognito userpool
Before opening, please confirm:
- [X] I have installed the latest version of the Amplify CLI (see above), and confirmed that the issue still persists.
- [X] I have searched for duplicate or closed issues.
- [X] I have read the guide for submitting bug reports.
- [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
How did you install the Amplify CLI?
npm
If applicable, what version of Node.js are you using?
8.x
Amplify CLI Version
7.6.12
What operating system are you using?
Mac and Windows
Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.
- custom attribute custom:company
- I added an own app client
- I added read to custom:company to the existing 2 app clients but reverted this and still same error
- I did not add analytics or sth new (as far as I know)
- I just added UI stuff
- I remember that my pretokenGeneration function was not assigned to Cognito anymore suddenly and I added it manually. But this is also some time ago
- I normally just git push and not amplify push. Nevertheless in this case both does not work,
Amplify Categories
auth
Amplify Commands
publish
Describe the bug
when doing amplify push, I get the error
"Invalid AttributeDataType input, consider using the provided AttributeDataType enum. (Service: AWSCognitoIdentityProviderService; Status Code: 400; Error Code: InvalidParameterException"
Expected behavior
run smoothly and deploy all changes
Reproduction steps
see https://github.com/aws-amplify/amplify-cli/issues/9525
GraphQL schema(s)
# Put schemas below this line
Log output
# Put your logs below this line
Additional information
See https://github.com/aws-amplify/amplify-cli/issues/9525#issuecomment-1020368077 and https://github.com/aws-amplify/amplify-cli/issues/9525#issuecomment-1020417480 for more details
There are more users with this problem like @sandeep-pracbee
Thanks for this (and all the details shared in https://github.com/aws-amplify/amplify-cli/issues/9525)! I am investigating potential causes.
I remember another suspicious thing: A few weeks ago my amplify user did not push anymore because I did not have the right to "cognito-idp:AddCustomAttributes". I have custom attribute custom:company but that worked without problems for half a year. I added the role and did not have problems after that.
As our project is not top secret, I have no problems to invite someone to our amplify project if that helps.
Some context for the error I am seeing.
amplify push worked locally via cli once after I re-added AdminQueries API. But when the next time, Amplify tried to deploy the changes on my master git branch (which has no backend/cognito changes) and the CI failed to build Backend.
After that, I after tried everything, amplify env pull --restore, pulling a new directory, etc, but this error just won't go away and as a result I can't deploy any new changes.
@johnpc I don't understand how this issue is different than #9525. You suggested that removing the amplify directory and doing an amplify pull might help there. If #9525 is only about the requiredAttributes being different in cli-inputs.json, then my post there should be here since my requiredAttributes are the same.
Here is a copy of it:
If you amplify pull this environment into a new directory, can you immediately not run amplify push? Sometimes when there's something borked in my local state, and I don't mind losing any local unpushed changes, I'll just remove my entire amplify directory and re-pull it back into my app.
I am having the same issue. amplify pull did not fix it.
Here is what I did:
- deleted the amplify directory
- amplify pull
- amplify push (Showed 'No Change' as expected)
- amplify remove storage (just to make a change to amplify)
- amplify push (Everything showed 'No Change', except storage which showed Delete)
- Are you sure you want to continue? Yes
Still get this error when pushing:
UPDATE_FAILED UserPool AWS::Cognito::UserPool Mon Jan 24 2022 12:32:06 GMT-0800 (Pacific Standard Time) Invalid AttributeDataType input, consider using the provided AttributeDataType enum. (Service: AWSCognitoIdentityProviderService; Status Code: 400; Error Code: InvalidParameterException; Request ID: c5760a9d-035f-4de7-a8ab-309a1fa7be7d; Proxy: null)
Also, my required attributes are correct, using amplify 7.6.12 now, and rolling back to amplify 7.6.8 before this did not work.
This solved it for me: https://github.com/aws-amplify/amplify-cli/issues/9525#issuecomment-1020860520
There was a difference between amplify/#current-cloud-backend/auth/myapp1234/build/myapp1234-cloudformation-template.json and amplify/backend/auth/myapp1234/cli-inputs.json
The #current-cloud-backend file had in my case only family_name and in cli-inputs.json I had email first_name, given_name and website.
It is still with all 4 elements in

@johnpc: it is running now but do we get into trouble in the future with this configuration? It sounds for me super strange that the cloudformation template does not show the right configuration of the userpool but when having the right configuration, it fails. Also cognito seems not to care.
Thank you so much @jladdison for finding a solution.
Hi all I am currently running into the same issue. I have no problem using amplify push locally; however, deploying through AWS console do fail during build.
I did also noticed that there seems to be a discripency between my set up User Pool required attributes just like @dbeck121 .
I do have it set up to have both email & phone number being required. But Cloudformation template only shows phone number being a required filed.
@SunnieBB it worked for me when reducing the cli-inputs.json file to whats required in the template.
@dbeck121 @jladdison yes this is a weird one. I'm glad to hear you're unblocked. Do you know if you created your auth resource before v7.3.0, and then made a change to it (such as what happens when adding analytics) during 7.3.0-7.6.9?
In that case it's possible that Amplify pushed a broken #current-cloud-backend state to your s3 bucket that cached the wrong requiredAttributes there.
@dbeck121 @jladdison yes this is a weird one. I'm glad to hear you're unblocked. Do you know if you created your auth resource before v7.3.0, and then made a change to it (such as what happens when adding analytics) during 7.3.0-7.6.9?
@johnpc Yes. It appears that is the case. I keep my cli up to date. The environment was created (with auth) on Nov 1, 2021 which would have likely been with v6.3.1. Storage was added on Dec 10, 2021 which would have likely been with v7.6.3.
The versions may be off slightly since I usually update the cli AFTER I do a push and see the message that there is an update.
@dbeck121 thanks for the response and great to know you have it running.
Did you mean to remove it manually in cli-inputs.json to match the cloud template file?
Did you mean to remove it manually in cli-inputs.json to match the cloud template file?
@SunnieBB yes. try changing the cli-inputs.json in the backend directory (not the #current-cloud-backend directory)
if amplify/backend/auth/myapp1234/cli-inputs.json has:
"requiredAttributes": [
"email",
"phone"
],
change it to:
"requiredAttributes": [
"phone"
],
Then try amplify push.
@jladdison Thanks for the prompt response. Even after the change you've mentioned above I am still getting the same error:
UPDATE_FAILED UserPool AWS::Cognito::UserPool Invalid AttributeDataType input, consider using the provided AttributeDataType enum. (Service: AWSCognitoIdentityProviderService; Status Code: 400; Error Code: InvalidParameterException; Request ID: 1d196568-eb71-44aa-a27d-6ba20462806c; Proxy: null)
Any other ways i can debug regarding this? Sorry this is my first time deploying through Amplify console
@SunnieBB are all the sections in all 4 files showing just the phone as a required attribute now? See https://github.com/aws-amplify/amplify-cli/issues/9525#issuecomment-1020860520 for the list of files.
I was not able to push from the CLI or deploy through the AWS console so you may have a slightly different issue.
If this is your first time deploying through the amplify console, do you have any users in Cognito that you cannot loose? If not, then I would suggest creating a new environment. (amplify init)
If you have users that you cannot loose, try 'amplify pull' on your local machine and then check all 4 files again. I am not sure if that will help or not, but it might show if something is out of sync with the cloud.
@jladdison
i have updated the amplify/backend/auth/myapp1234/cli-inputs.json by removing email:
"requiredAttributes": [
"phone_number"
],
which now matches amplify/backend/auth/myapp1234/build/myapp1234-cloudformation-template.json:
"Schema": [
{
"Mutable": true,
"Name": "phone_number",
"Required": true
}
],
Then ran amplify push. I was curious if i had to push the changes to github as well since my deployment is through github so there arent any discripency.
If after pushing to github wont work. I'll try 'amplify pull' and try again.
@jladdison and everyone here, thanks for all help. Successfully deployed now. Seems like after changing the files, I needed to push the changes to github.
@SunnieBB Yes, the changes always need to be pushed to your repo. When you make changes to the repo, the cloud build is triggered. It then clones the repo and builds from that. If you don't push your local changes to github, then it won't have them when it builds.
I still can't push due to a problem with cognito, this is my cli-inputs.json:
{
"version": "1",
"cognitoConfig": {
"identityPoolName": "medu1b342794_identitypool_1b342794",
"allowUnauthenticatedIdentities": true,
"resourceNameTruncated": "medu1b342794",
"userPoolName": "medu1b342794_userpool_1b342794",
"autoVerifiedAttributes": [
"email"
],
"mfaConfiguration": "OFF",
"mfaTypes": [
"SMS Text Message"
],
"smsAuthenticationMessage": "Your authentication code is {####}",
"smsVerificationMessage": "Your verification code is {####}",
"emailVerificationSubject": "Your verification code",
"emailVerificationMessage": "Your verification code is {####}",
"defaultPasswordPolicy": false,
"passwordPolicyMinLength": 8,
"passwordPolicyCharacters": [],
"requiredAttributes": [
"birthdate",
"email",
"family_name",
"name"
],
"aliasAttributes": [],
"userpoolClientGenerateSecret": true,
"userpoolClientRefreshTokenValidity": 30,
"userpoolClientWriteAttributes": [
"email"
],
"userpoolClientReadAttributes": [
"email"
],
"userpoolClientLambdaRole": "medu1b1b342794_userpoolclient_lambda_role",
"userpoolClientSetAttributes": false,
"authSelections": "identityPoolAndUserPool",
"resourceName": "medu1b342794",
"serviceName": "Cognito",
"useDefault": "manual",
"sharedId": "1b342794",
"userPoolGroupList": [
"Admin",
"MeduAdmins",
"MeduClients",
"MeduUsers"
],
"userPoolGroups": true,
"usernameAttributes": [
"email"
],
"adminQueries": true,
"hostedUI": false,
"thirdPartyAuth": false,
"authProviders": [],
"triggers": {
"PostConfirmation": [
"add-to-group",
"custom"
],
"PreSignup": [
"email-filter-denylist-legacy"
]
},
"authRoleArn": {
"Fn::GetAtt": [
"AuthRole",
"Arn"
]
},
"unauthRoleArn": {
"Fn::GetAtt": [
"UnauthRole",
"Arn"
]
},
"breakCircularDependency": false,
"useEnabledMfas": false,
"dependsOn": [
{
"category": "function",
"resourceName": "medu1b342794PostConfirmation",
"triggerProvider": "Cognito",
"attributes": [
"Arn",
"Name"
]
},
{
"category": "function",
"resourceName": "medu1b342794PreSignup",
"triggerProvider": "Cognito",
"attributes": [
"Arn",
"Name"
]
}
],
"permissions": [
"{\n \"policyName\": \"AddToGroupCognito\",\n \"trigger\": \"PostConfirmation\",\n \"effect\": \"Allow\",\n \"actions\": [\n \"cognito-idp:AdminAddUserToGroup\",\n \"cognito-idp:GetGroup\",\n \"cognito-idp:CreateGroup\"\n ],\n \"resource\": {\n \"paramType\": \"!GetAtt\",\n \"keys\": [\n \"UserPool\",\n \"Arn\"\n ]\n }\n}"
],
"authTriggerConnections": [
"{\"triggerType\":\"PostConfirmation\",\"lambdaFunctionName\":\"medu1b342794PostConfirmation\"}",
"{\"triggerType\":\"PreSignUp\",\"lambdaFunctionName\":\"medu1b342794PreSignup\"}"
],
"parentStack": {
"Ref": "AWS::StackId"
}
}
}
I am having a similar problem...I have done the following with the latest version:
- clone, init, pull
- status - no changes
- made a change to API (added a field)
- push - api shows as changed - fails with Invalid AttributeDataType input, consider using the provided AttributeDataType enum.
- removed the change to API in step 3
- push - shows no changes - but still attempts to push and fails with Invalid AttributeDataType input, consider using the provided AttributeDataType enum.
There are no changes to any files under source control showing at the end of this...
It seems that making a change to API triggers a change to auth, which will then fail, and is undetected by status (but still is attempting to push)
If I compare the two templates (from current and backend) the differences are:
removed: "hostedUIProviderCreds": { "Type": "String" },
new: { "Mutable": true, "Name": "email", "Required": true }, { "Mutable": true, "Name": "family_name", "Required": true }, { "Mutable": true, "Name": "given_name", "Required": true },
@johnpc - is this a separate issue from #9525 - since this doesn't seem to be analytics related...or is this just a bigger problem with auth drift in Amplify or an issue with incorporating legacy drift/changes into the new system? It may be necessary until this is all figured out to let us edit the templates before they are pushed...(I am assuming that might fix most of these issues)...