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

fetchUserAttributes() throws an error ResourceNotFoundException: IdentityPool 'us-west-1:xxx-xxx-xxx' not found. #13603

Closed
3 tasks done
mark-carlson opened this issue Jan 24, 2024 · 14 comments
Labels
auth Issues tied to the auth category of the CLI pending-response Issue is pending response from the issue author pending-triage Issue is pending triage question General question

Comments

@mark-carlson
Copy link

Before opening, please confirm:

JavaScript Framework

React

Amplify APIs

Authentication, GraphQL API

Amplify Version

v6

Amplify Categories

auth

Backend

Amplify CLI

Environment information

# Put output below this line
System:
    OS: macOS 14.2.1
    CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 167.40 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.10.0 - ~/.nvm/versions/node/v20.10.0/bin/node
    Yarn: 1.5.1 - /usr/local/bin/yarn
    npm: 10.2.3 - ~/.nvm/versions/node/v20.10.0/bin/npm
  Browsers:
    Chrome: 120.0.6099.234
    Safari: 17.2.1
  npmPackages:
    @aws-amplify/ui-react: ^6.0.6 => 6.0.6 
    @aws-amplify/ui-react-internal:  undefined ()
    @cloudscape-design/components: ^3.0.465 => 3.0.465 
    @cloudscape-design/global-styles: ^1.0.20 => 1.0.20 
    @storybook/addon-essentials: ^7.6.5 => 7.6.5 
    @storybook/addon-interactions: ^7.6.5 => 7.6.5 
    @storybook/addon-links: ^7.6.5 => 7.6.5 
    @storybook/addon-onboarding: ^1.0.10 => 1.0.10 
    @storybook/blocks: ^7.6.5 => 7.6.5 
    @storybook/react: ^7.6.5 => 7.6.5 
    @storybook/react-vite: ^7.6.5 => 7.6.5 
    @storybook/test: ^7.6.5 => 7.6.5 
    @types/react: ^18.2.43 => 18.2.45 
    @types/react-dom: ^18.2.17 => 18.2.18 
    @vitejs/plugin-react-swc: ^3.5.0 => 3.5.0 
    aws-amplify: ^6.0.7 => 6.0.7 
    aws-amplify/adapter-core:  undefined ()
    aws-amplify/analytics:  undefined ()
    aws-amplify/analytics/kinesis:  undefined ()
    aws-amplify/analytics/kinesis-firehose:  undefined ()
    aws-amplify/analytics/personalize:  undefined ()
    aws-amplify/analytics/pinpoint:  undefined ()
    aws-amplify/api:  undefined ()
    aws-amplify/api/server:  undefined ()
    aws-amplify/auth:  undefined ()
    aws-amplify/auth/cognito:  undefined ()
    aws-amplify/auth/cognito/server:  undefined ()
    aws-amplify/auth/server:  undefined ()
    aws-amplify/datastore:  undefined ()
    aws-amplify/in-app-messaging:  undefined ()
    aws-amplify/in-app-messaging/pinpoint:  undefined ()
    aws-amplify/push-notifications:  undefined ()
    aws-amplify/push-notifications/pinpoint:  undefined ()
    aws-amplify/storage:  undefined ()
    aws-amplify/storage/s3:  undefined ()
    aws-amplify/storage/s3/server:  undefined ()
    aws-amplify/storage/server:  undefined ()
    aws-amplify/utils:  undefined ()
    eslint: ^8.55.0 => 8.56.0 
    eslint-plugin-react: ^7.33.2 => 7.33.2 
    eslint-plugin-react-hooks: ^4.6.0 => 4.6.0 
    eslint-plugin-react-refresh: ^0.4.5 => 0.4.5 
    eslint-plugin-storybook: ^0.6.15 => 0.6.15 
    plop: ^4.0.1 => 4.0.1 
    plop-example:  undefined ()
    plop-example-action-failure:  undefined ()
    plop-example-add-action:  undefined ()
    plop-example-prompts-only:  undefined ()
    plop-example-wrap:  undefined ()
    prop-types: ^15.8.1 => 15.8.1 
    react: ^18.2.0 => 18.2.0 
    react-dom: ^18.2.0 => 18.2.0 
    react-router-dom: ^6.21.0 => 6.21.0 
    storybook: ^7.6.5 => 7.6.5 
    vite: ^5.0.8 => 5.0.10 
  npmGlobalPackages:
    @aws-amplify/cli: 12.10.0
    corepack: 0.22.0
    npm: 10.2.3

Describe the bug

I've added name as a standard attribute in Cognito sign up user pool and have set read/write permissions properly.

When a user registers, the name value (when selected) appears in the Cognito console.
Screenshot 2024-01-23 at 10 31 01 PM

However, when I call getCurrentUser(), the only properties in the object are userId, username, and signInDetails. signInDetails contains a loginId and an authFlowType.

I would like the front end React app to have access to the standard name attribute. Documentation here seems to indicate that using fetchUserAttributes() will provide this data.

However, I get this error in my console:

Screenshot 2024-01-23 at 10 35 34 PM

I do not use identity pools. I am trying to get a standard attribute from a user pool.

Expected behavior

When calling fetchUserAttributes(), the method should return an object containing any standard or custom attributes in my Cognito user pool.

Reproduction steps

  1. Set up Cognito to use one or more standard attributes like name, given name, family name, etc. in your user pool.
  2. Confirm in the AWS console that Cognito has captured this data in your user pool on Sign Up.
  3. Use fetchUserAttributes() in your front end code to try to retrieve the values of these standard attributes.

Code Snippet

// Put your code below this line.
import { getCurrentUser, fetchUserAttributes } from "aws-amplify/auth";

  const getUserData = async () => {
    try {
      const currentUser = await getCurrentUser();
      console.log("currentUser", currentUser); // this logs an object with a userId and username.   No attributes are included.
      const attributes = await fetchUserAttributes(); // <-- This line throws an error
      console.log("attributes", attributes);
    } catch (error) {
      console.log("error", error);
    }
  };

Log output

// Put your logs below this line


aws-exports.js

No response

Manual configuration

No response

Additional configuration

No response

Mobile Device

No response

Mobile Operating System

No response

Mobile Browser

No response

Mobile Browser Version

No response

Additional information and screenshots

No response

@mark-carlson mark-carlson added the pending-triage Issue is pending triage label Jan 24, 2024
@nadetastic nadetastic added the auth Issues tied to the auth category of the CLI label Jan 24, 2024
@nadetastic nadetastic self-assigned this Jan 24, 2024
@israx
Copy link
Member

israx commented Jan 24, 2024

hello @mark-carlson , can you try upgrading amplify to the latest version and see if you still experience this issue ?

Also just in case, you will get an exception if you are passing an invalid identityPoolId in your config, if you are not using identity pools, try to avoid including one.

@mark-carlson
Copy link
Author

Hi @israx . I can confirm I am on the latest version of amplify and have no identityPoolId in my config. After updating to v6.0.13, I still have this issue.

@mark-carlson
Copy link
Author

By the way, I would also be happy if getCurrentUser() returned any existing standard attributes.

@israx
Copy link
Member

israx commented Jan 24, 2024

I'm able to reproduce this issue when I have an invalid identity pool in the config, once I remove it, it works as expected. Can you share your amplify configuration without showing any sensitive information ?

Yeah returning standard attributes from getCurrentUser() should be a feature request for now. If you want you could open a new GitHub issue so we can triage it accordingly

@mark-carlson
Copy link
Author

Thank you, @israx. I can confirm that I did indeed have an identity-pool-id in my config. One of them was in an auto-generated file aws-exports.js. I removed it manually. Is there a way to remove this entry with amplify-cli?

@israx
Copy link
Member

israx commented Jan 24, 2024

did you try running amplify auth remove ?

@mark-carlson
Copy link
Author

did you try running amplify auth remove ?

I did not. Was afraid of throwing out the baby with the bathwater. But that would be a valid way to start fresh, I guess. Thank you again for pointing out the cause and solution!

@nadetastic nadetastic added question General question and removed pending-triage Issue is pending triage labels Feb 13, 2024
@jkellyinsf
Copy link

I have the same problem. I tried removing and recreating the auth, rebuilding the lambda trigger, resetting permissions, and still have the same problem. It seems to get better if I manually delete the aws_cognito_identity_pool_id from my local amplifyconfiguration.json, but how did it get there? This file gets generated from something, doesn't it?

@mark-carlson
Copy link
Author

@jkellyinsf, this problem has happened repeatedly for me since I closed the issue. Everytime it happens, I go through searching for identity pool ids to remove from my configs.

@nadetastic
Copy link
Member

Hi @mark-carlson due to this consistently happening, I'll re-open this issue and mark it as a bug and discuss it with the team. I will follow up with updates asap.

@nadetastic nadetastic reopened this Feb 19, 2024
@nadetastic nadetastic added the bug Something isn't working label Feb 19, 2024
@nadetastic nadetastic transferred this issue from aws-amplify/amplify-js Feb 20, 2024
@ykethan ykethan added pending-triage Issue is pending triage and removed bug Something isn't working labels Feb 21, 2024
@ykethan
Copy link
Member

ykethan commented Feb 21, 2024

Hey @mark-carlson, had a quick question, was the identity pool created by Amplify CLI removed on the AWS Cognito console?

we can just create a user pool without an identity pool, by utilizing the following on update/add auth on the following option.

 Do you want to use the default authentication and security configuration? Manual configuration
 Select the authentication/authorization services that you want to use: User Sign-Up & Sign-In only (Best used with a cloud API only)

On each push/pull amplify regenerates the amplifyconfiguration.json or aws-exports.js files

@ykethan ykethan added the pending-response Issue is pending response from the issue author label Feb 21, 2024
@CoderDake
Copy link

I ran into this as well and can confirm that removing the aws_cognito_identity_pool_id line from my amplifyconfiguration.json seems to have fixed it.

@ykethan
Copy link
Member

ykethan commented May 29, 2024

Closing the issue due to inactivity. Do reach out to us if you are still experiencing this issue

@ykethan ykethan closed this as not planned Won't fix, can't repro, duplicate, stale May 29, 2024
Copy link

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auth Issues tied to the auth category of the CLI pending-response Issue is pending response from the issue author pending-triage Issue is pending triage question General question
Projects
None yet
Development

No branches or pull requests

6 participants