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

Empty API Mock editor #1269

Closed
2 tasks done
dan-hook opened this issue Feb 4, 2023 · 31 comments
Closed
2 tasks done

Empty API Mock editor #1269

dan-hook opened this issue Feb 4, 2023 · 31 comments
Labels
bug Something isn't working mock p2 theme:mock

Comments

@dan-hook
Copy link

dan-hook commented Feb 4, 2023

How did you install the Amplify CLI?

npm

If applicable, what version of Node.js are you using?

v18.14.0

Amplify CLI Version

10.7.0

What operating system are you using?

Ubuntu 22.04 on WSL2 on Windows 10

Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.

Yes, the changes are extensive.

Describe the bug

I ran apt-get install java-11-amazon-corretto-jdk to install Java.

Running amplify mock api launches Amplify GraphiQL Explore on localhost:20002, but it's empty saying "No Schema Available".
The CLI output is:
vscode ➜ .../panel-api/project/amplify/backend (features/VCD-504-ecv-api ✗) $ amplify mock api
GraphQL schema compiled successfully.

Edit your schema at /workspaces/gene-panel-api/project/amplify/backend/api/genepanelapi/schema.graphql or place .graphql files in a directory at /workspaces/gene-panel-api/project/amplify/backend/api/genepanelapi/schema
Mock does not handle CloudFormation resource of type AWS::IAM::ManagedPolicy. Skipping processing resource AuthRolePolicy01.
Mock does not handle CloudFormation resource of type AWS::IAM::ManagedPolicy. Skipping processing resource AuthRolePolicy02.
Mock does not handle CloudFormation resource of type AWS::IAM::ManagedPolicy. Skipping processing resource AuthRolePolicy03.
Data source of type RELATIONAL_DATABASE is not supported by local mocking. A NONE data source will be used.
Data source of type HTTP is not supported by local mocking. A NONE data source will be used.
Data source of type HTTP is not supported by local mocking. A NONE data source will be used.
Data source of type HTTP is not supported by local mocking. A NONE data source will be used.
Could not find ref for "RdsPanelDbName". Using unsubstituted value.
Could not find ref for "RdsPanelDbName". Using unsubstituted value.
Running GraphQL codegen
✔ Generated GraphQL operations successfully and saved at ../../src/graphql
AppSync Mock endpoint is running at http://172.17.0.2:20002
Re-Trying with a new shard
Re-Trying with a new shard
Re-Trying with a new shard
Re-Trying with a new shard
Re-Trying with a new shard
Re-Trying with a new shard
Re-Trying with a new shard
Re-Trying with a new shard
Re-Trying with a new shard
Re-Trying with a new shard
Re-Trying with a new shard
Re-Trying with a new shard
Re-Trying with a new shard
Re-Trying with a new shard
Re-Trying with a new shard
Re-Trying with a new shard
Re-Trying with a new shard
Re-Trying with a new shard
Re-Trying with a new shard
Re-Trying with a new shard
Re-Trying with a new shard
Re-Trying with a new shard
Re-Trying with a new shard
Re-Trying with a new shard
Re-Trying with a new shard
Re-Trying with a new shard
Re-Trying with a new shard
Mock DB deletion detected. Clearing the OpenSearch indices...
Re-Trying with a new shard
Re-Trying with a new shard
Failed to start API Mocking. Running cleanup tasks.
MockProcessFault: Failed to start API Mocking.. Reason: null
at APITest.start (/snapshot/repo/build/node_modules/amplify-util-mock/lib/api/api.js:151:13)
at runMicrotasks ()
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at async start (/snapshot/repo/build/node_modules/amplify-util-mock/lib/api/index.js:18:5)
at async Object.run (/snapshot/repo/build/node_modules/amplify-util-mock/lib/commands/mock/api.js:21:5)
at async Object.executeAmplifyCommand (/snapshot/repo/build/node_modules/amplify-util-mock/lib/amplify-plugin-index.js:47:3)
at async executePluginModuleCommand (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/execution-manager.js:142:5)
at async executeCommand (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/execution-manager.js:40:9)
at async Object.run (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/index.js:117:5) {
classification: 'FAULT',
options: {
message: 'Failed to start API Mocking.. Reason: null',
link: 'https://docs.amplify.aws/cli/graphql/troubleshooting/'
},
downstreamException: undefined,
toObject: [Function (anonymous)],
details: undefined,
resolution: undefined,
code: undefined,
link: 'https://docs.amplify.aws/cli/graphql/troubleshooting/'
}

Expected behavior

I expected to see the API in the explorer.

Reproduction steps

Run 'amplify mock api'

Project Identifier

9c19ea5526c1afd0a3e1987ea44f96af

Log output

# Put your logs below this line


Additional information

No response

Before submitting, please confirm:

  • I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
  • I have removed any sensitive information from my code snippets and submission.
@raphipaffi
Copy link

I have the same issue. Also using amplify 10.7.0. I am on a Mac M1. Looks very similar to this issue that already got resolved in 9.0.0 couple months ago: aws-amplify/amplify-cli#10578

@issakr
Copy link

issakr commented Feb 6, 2023

Same issue on amplify 10.7.1. I am also on a Mac M1.

@josefaidt
Copy link
Contributor

Hey @dan-hook 👋 thanks for raising this! Was the amplify/mock-data directory deleted before mock finished initializing? Looking at this log item:

Mock DB deletion detected. Clearing the OpenSearch indices...

@raphipaffi @issakr on M1 macs you will need to install the 64-bit version of Java
image

For example, this is the Java version I am running locally on my M1 mac

➜  java -version
openjdk version "18.0.1.1" 2022-04-22
OpenJDK Runtime Environment (build 18.0.1.1+2-6)
OpenJDK 64-Bit Server VM (build 18.0.1.1+2-6, mixed mode, sharing)

@issakr
Copy link

issakr commented Feb 6, 2023

I already use openjdk
`➜ java -version

openjdk version "17.0.4.1" 2022-08-12
OpenJDK Runtime Environment Temurin-17.0.4.1+1 (build 17.0.4.1+1)
OpenJDK 64-Bit Server VM Temurin-17.0.4.1+1 (build 17.0.4.1+1, mixed mode)`

@dan-hook
Copy link
Author

dan-hook commented Feb 6, 2023

Hey @dan-hook 👋 thanks for raising this! Was the amplify/mock-data directory deleted before mock finished initializing? Looking at this log item:

Mock DB deletion detected. Clearing the OpenSearch indices...

I think that log item is spurious and may have even been caused by my computer going to sleep. There was 5-10 minutes between each "Re-Trying with a new shard". I stopped checking the Explorer after about six of them.

This is a complicated Amplify project and this is the first time I've tried running aws mock api on it. There were a number of issues such as VTL parsing errors that I needed to fix before I got this far, and I'm not surprised that there are still more issues. I'm not surprised it doesn't work, I just wish there was a better error message.

@raphipaffi
Copy link

raphipaffi commented Feb 10, 2023

I already have Java 64bit installed

➜ route-planner git:(master) ✗ java -version
openjdk version "19.0.2" 2023-01-17
OpenJDK Runtime Environment Homebrew (build 19.0.2)
OpenJDK 64-Bit Server VM Homebrew (build 19.0.2, mixed mode, sharing)

Let me know if there is anything else I can try.

@josefaidt
Copy link
Contributor

josefaidt commented Feb 14, 2023

Hey @raphipaffi @issakr given the M1 issue is different than what this issue is describing, would y'all mind filing a separate bug report to track your issue separately? We want to be sure this is addressed and documentation is updated if necessary. Do you experience the same issue using the official distribution from the OpenJDK downloads page?

@dan-hook

This is a complicated Amplify project and this is the first time I've tried running aws mock api on it.

Would you be open to sharing your schema.graphql? Do you have any overridden, slotted resolvers or custom resolvers that are causing the VTL parsing errors?

Upon further review of the error messaging I see the following error, are you using a Relational Database with your GraphQL API?

Data source of type RELATIONAL_DATABASE is not supported by local mocking. A NONE data source will be used.

@NicholasAllen
Copy link

I also started suffering this issue. I was trying on the 10.7.3 and 10.7.2 client builds. The following comment helped me resolve it for now: aws-amplify/amplify-cli#10488 (comment) - downgrade to 10.6.2 and it's working again.

@raphipaffi
Copy link

@NicholasAllen thank you so much for that tip! That downgrade also "fixed" it for me.

@josefaidt josefaidt transferred this issue from aws-amplify/amplify-cli Feb 18, 2023
@josefaidt
Copy link
Contributor

josefaidt commented Feb 18, 2023

Hey folks I'm able to reproduce this issue using the Todo schema. Marking as a bug
image

@kmy90
Copy link

kmy90 commented Apr 4, 2023

Hi, there is an ETA for the resolution of this bug?

@dwamianm
Copy link

dwamianm commented Apr 17, 2023

@josefaidt. We are still experiencing this issue in 11.0.5. Any update on the fix?

FYI. Clearing mock files does not help. . I have @searchable annotations so I am unable to go back to 10.x.x

@espenbye
Copy link

We are experiencing the same issue on 11.0.5.

@dwamianm
Copy link

@josefaidt @phani-srikar This issue still exists in 11.1.0.

I would love to have this addressed if possible. I cannot downgrade to 10.6.2 because I am using OpenSearch mocking, which is only available in 11.x.x. I realize this may not seem like a priority but as a longtime Amplify. user it's a huge disadvantage to not have this feature in API mocking.

Any updates?

@dwamianm
Copy link

dwamianm commented Jun 5, 2023

@josefaidt @phani-srikar ... any updates on this bug? It has really slowed development to not be able to use the tools to test locally. I am commenting here because It has been so long and I would really love to get this bug addressed so I can be on an updated amplify version. I am still stuck on 10.6.2 just to be able to get this to work :(

@dwamianm
Copy link

Checking for any updates on this bug. Still exists in 12.1.0

@remotehpc
Copy link

Hey folks I'm able to reproduce this issue using the Todo schema. Marking as a bug image

Hi Josef, are you able to resolve the bug or provide a walkaround? My team has been stuck here for too long, any help would be greatly appreciated!

Best regards!

@aoi
Copy link

aoi commented Jul 6, 2023

@josefaidt Hi josefaidt.

Thank you for your response.

You have transfered this issue from amplify-cli repository to here.
But the code has probrem is not in this repository. It is in amplify-cli repository.
Please see my PR in amplify-cli repository.

amplify mock is very useful and important function for developers. A lot of developers are stuck in this bug for months.
I would appreciate it if you could respond promptly.

Best regards,

@pridapablo
Copy link

I found that the error directly comes from adding Cognito User Pool auth to the api, no matter if API or IAM is also enabled. Working with amplify -v 12.0.0 since amplify mocks fail completely on m2 Mac using the latest version of the cli.

@jmelendev
Copy link

Im using -v 12.2.0 and seeing the same issues. I am seeing the following error in the console:

"Error: Error when generating OIDC token: Right-hand side of 'instanceof' is not an object"

Screen Shot 2023-07-26 at 9 35 59 PM

This was working fine earlier today, not sure what changed recently.

@araymond11
Copy link

Any updates ? Same issue with Amplify CLI version 12.3.0.

@kita3222
Copy link
Contributor

kita3222 commented Sep 27, 2023

I have confirmed that it also occurs in v12.4.0.

@araymond11
Copy link

Still occurs in v12.7.0.

@afnx
Copy link

afnx commented Nov 20, 2023

It's been months and still not able to see anything on Amplify GraphiQL Explorer.

There is this Uncaught (in promise) Error: Error when generating OIDC token: invalid 'instanceof' operand g error that everybody mentioned on my browser console.

Also, when I try to execute a query, I always get the unauthorized error:

{
  "errors": [
    {
      "errorType": "UnauthorizedException",
      "message": "UnauthorizedException: Missing authorization"
    }
  ]
}

@zakton5
Copy link

zakton5 commented Nov 21, 2023

As mentioned by others developing and testing locally is very important and without it the development process is far slower. @josefaidt Are there any updates?

@kmy90
Copy link

kmy90 commented Dec 18, 2023

Hi everyone, this issue was opened almost 1 year ago. It is NOT a MINOR bug. There are teams around the world that are not able to use the latest version of Amplify just because of this problem. Could you help us, @josefaidt, @alharris-at ?

@rafadpedrosa
Copy link

I would like to share my experience, maybe will help someone.

Yes, I'm having the same issue as everyone. But, given that I use nvm to control my node versions, I "manage" to deal with this problem installing different amplify-cli version on different node version as mentioned here.

nvm use 20 
npm install npm install -g @aws-amplify

nvm use 18 
npm install -g @aws-amplify/[email protected] // working version

Also, I do agree with @kmy90. It should not be treated as a minor thing.

@afnx
Copy link

afnx commented Jan 31, 2024

Hey folks, this is a serious issue here impacting everyone and disrupting the development process. Using workarounds, like downgrading the Amplify version, isn't the most convenient solution. Personally, I struggled with testing my projects locally using the explorer, and it really bothered me that such an important issue had been left unattended for a year.

I fixed it by creating a PR (aws-amplify/amplify-cli#13555). Can you please support it? We need the Amplify team to review and approve the fix. Thanks!

@zepelega
Copy link

Still occurs in v12.10.1.

@afnx
Copy link

afnx commented Apr 25, 2024

Fixed in version 12.11.0

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
bug Something isn't working mock p2 theme:mock
Projects
None yet
Development

No branches or pull requests