GoogleCloudPlatform / google-cloud-eclipse

Google Cloud Platform plugin for Eclipse
Apache License 2.0
86 stars 49 forks source link

[Project Selector] Missing error detail in retrieval-error dialog #2090

Open briandealwis opened 7 years ago

briandealwis commented 7 years ago
screen shot 2017-06-28 at 4 48 51 pm
chanseokoh commented 7 years ago

https://github.com/GoogleCloudPlatform/google-cloud-eclipse/blob/v1.2.0B/plugins/com.google.cloud.tools.eclipse.appengine.deploy.ui/src/com/google/cloud/tools/eclipse/appengine/deploy/ui/GcpProjectQueryJob.java#L87

Should have put ex.getLocalizedMessage() to the placeholder.

BTW, I am curious what was the actual failure. That should rarely fail. Can you check the details in the Error Log view?

briandealwis commented 7 years ago

Hmm, the actual underlying exception was:

!ENTRY com.google.cloud.tools.eclipse.appengine.deploy.ui 4 0 2017-06-28 16:48:50.138
!MESSAGE An error occurred while retrieving projects: {0}
!STACK 0
com.google.cloud.tools.eclipse.projectselector.ProjectRepositoryException: com.google.api.client.auth.oauth2.TokenResponseException: 401 Unauthorized
    at com.google.cloud.tools.eclipse.projectselector.ProjectRepository.getProjects(ProjectRepository.java:64)
    at com.google.cloud.tools.eclipse.appengine.deploy.ui.GcpProjectQueryJob.run(GcpProjectQueryJob.java:71)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:56)
Caused by: com.google.api.client.auth.oauth2.TokenResponseException: 401 Unauthorized
    at com.google.api.client.auth.oauth2.TokenResponseException.from(TokenResponseException.java:105)
    at com.google.api.client.auth.oauth2.TokenRequest.executeUnparsed(TokenRequest.java:287)
    at com.google.api.client.auth.oauth2.TokenRequest.execute(TokenRequest.java:307)
    at com.google.api.client.auth.oauth2.Credential.executeRefreshToken(Credential.java:570)

Not sure if com.google.api.client.auth.oauth2.TokenResponseException: 401 Unauthorized is a great message to report back.

briandealwis commented 7 years ago

This job shouldn't report errors directly to the user as it's doing currently. The AppEngineDeployPreferencesPanel should have a job listener and report the status somehow in the dialog. We should call setProperty(IProgressConstants.NO_IMMEDIATE_ERROR_PROMPT_PROPERTY, true).

It's difficult for the user to know what should be done in this situation. What's odd is that I retried a couple of times and then it magically worked.

Since the user had previously logged into the account, perhaps in a 401 we should effectively discard the saved token information and re-start the authorization but with that account?

chanseokoh commented 7 years ago

Seems like OAuth2 credential was trying to refresh itself. Maybe the refresh should always succeed, but it didn't a couple of times due to some transient errors?

briandealwis commented 7 years ago

Refresh could fail if the user has revoked access (https://myaccount.google.com/permissions).