edgafner / dorkag

Issue Tracker repository for all Dorkag plugins
Other
5 stars 0 forks source link

Unhandled exception in [CoroutineName(com.gafner.plugin.azd.AZDProjectsManagerImpl) #59

Open ristomatti opened 9 months ago

ristomatti commented 9 months ago

I've been getting this exception on startup for some time. Besides this, the tool window has disappeared.

Unhandled exception in [CoroutineName(com.gafner.plugin.azd.AZDProjectsManagerImpl), StandaloneCoroutine{Cancelling}@206fe387, Dispatchers.Default]

java.lang.NullPointerException: getHost(...) must not be null
    at com.gafner.plugin.azd.util.git.AZDHosting.matchAZD(gitAsyncExtensions.kt:106)
    at com.gafner.plugin.azd.util.git.GitAsyncExtensionsKt$mapToServers$1$1.invoke(gitAsyncExtensions.kt:69)
    at com.gafner.plugin.azd.util.git.GitAsyncExtensionsKt$mapToServers$1$1.invoke(gitAsyncExtensions.kt:67)
    at kotlin.sequences.TransformingSequence$iterator$1.next(Sequences.kt:210)
    at kotlin.sequences.FilteringSequence$iterator$1.calcNext(Sequences.kt:170)
    at kotlin.sequences.FilteringSequence$iterator$1.hasNext(Sequences.kt:194)
    at kotlin.sequences.SequencesKt___SequencesKt.toSet(_Sequences.kt:841)
    at com.gafner.plugin.azd.util.git.GitAsyncExtensionsKt$mapToServers$1.invokeSuspend(gitAsyncExtensions.kt:73)
    at com.gafner.plugin.azd.util.git.GitAsyncExtensionsKt$mapToServers$1.invoke(gitAsyncExtensions.kt)
    at com.gafner.plugin.azd.util.git.GitAsyncExtensionsKt$mapToServers$1.invoke(gitAsyncExtensions.kt)
    at kotlinx.coroutines.flow.FlowKt__ZipKt$combine$1$1.invokeSuspend(Zip.kt:33)
    at kotlinx.coroutines.flow.FlowKt__ZipKt$combine$1$1.invoke(Zip.kt)
    at kotlinx.coroutines.flow.FlowKt__ZipKt$combine$1$1.invoke(Zip.kt)
    at kotlinx.coroutines.flow.internal.CombineKt$combineInternal$2.invokeSuspend(Combine.kt:76)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108)
    at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:584)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:793)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:697)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:684)
    Suppressed: java.lang.NullPointerException: getHost(...) must not be null
        at com.gafner.plugin.azd.util.git.AZDHosting.matchAZD(gitAsyncExtensions.kt:106)
        at com.gafner.plugin.azd.util.git.GitAsyncExtensionsKt$discoverServers$1$1.invokeSuspend(gitAsyncExtensions.kt:82)
        at com.gafner.plugin.azd.util.git.GitAsyncExtensionsKt$discoverServers$1$1.invoke(gitAsyncExtensions.kt)
        at com.gafner.plugin.azd.util.git.GitAsyncExtensionsKt$discoverServers$1$1.invoke(gitAsyncExtensions.kt)
        ... 10 more
    Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [CoroutineName(com.gafner.plugin.azd.AZDProjectsManagerImpl), StandaloneCoroutine{Cancelled}@206fe387, Dispatchers.Default]
Jonatha1983 commented 9 months ago

Ho @ristomatti Thanks for reporting Which version?

ristomatti commented 9 months ago

The latest, but this has been ongoing for I think several months. I just haven't been using Webstorm much lately due to it's TS engine slowness issues.

Jonatha1983 commented 9 months ago

@ristomatti Hi

I didn't get the real reason for this, but in the last published version, 2024.1.24, I added an extra NPE validation in the function throwing the exception.

Can you upgrade and let me know if the issue persists, please? In any case, I will keep this issue open for a few more days.

And I appreciate your help in reporting the bug. Thanks so much!!

Jonatha1983 commented 9 months ago

Sorry, the version with a possible fix will be uploaded today and hopefully will be available on Monday after JetBrains review and approval.

ristomatti commented 8 months ago

Still no update. I've been reviewing more pull requests lately. Could you provide the jar file through some channel to install manually?

Jonatha1983 commented 8 months ago

Hi @ristomatti The version was approved two days ago: https://plugins.jetbrains.com/plugin/22319-azd/edit/versions 2024.1.27

Did the bug happen in this version as well?

ristomatti commented 8 months ago

Odd, check for updates did not show it. Might be because I had it disabled to stop the error spam (even though even disabled plugins normally do update). After updating, I no more got the exception on IDE startup and could once again access the tool window. I could not retrieve pull requests though. You perhaps receiverd this through analytics but I see this error when clicking "Show pull requests":

Could not connect to repository https://dev.azure.com/REDACTED/REDACTED with account https://dev.azure.com/REDACTED@REDACTED Deserialization of Request POST https://vssps.dev.azure.com/REDACTED/_apis/graph/subjectquery?api-version=7.2-preview.1 response to JSON failed - Can't parse Azure Devops response: Instantiation of [simple type, class com.gafner.plugin.azd.api.dto.AzureDevopsAuthenticatedProfiles] value failed for JSON property value due to missing (therefore NULL) value for creator parameter value which is a non-nullable type at [Source: (InputStreamReader); line: 1, column: 24] (through reference chain: com.gafner.plugin.azd.api.dto.AzureDevopsAuthenticatedProfiles["value"])

...and a request to login again, which did not change anything.

Jonatha1983 commented 8 months ago

@ristomatti When you go here: https://app.vssps.visualstudio.com/_apis/profile/profiles/me

Do you see the right Azure DevOps user's email ( the one you create the PAT for)

Jonatha1983 commented 8 months ago

Another question - was the PAT created with "vso.graph" scope?

ristomatti commented 8 months ago

When I open the link, I'm first greeted with an account picker. If I select the one registered under the customer org's domain (not an actual email, the account name just had to be in the form of an email address), I see my own work email which I've configured as the email to use on the account settings in order to get notifications. This is the same account that I previously had issues with earlier (#15, #21). The PAT is also the same I used then.

It's got VSO Graph (read) if that is what "vso.graph" is the ID for.

ristomatti commented 8 months ago

So to clarify, I've got two Azure accounts which both use the same email. The other one uses that email as the login email while the other one uses a "fake" email under my customer's domain as the login. The PAT I is created while logged in to the one created by my customer, since the repos I work with are there.

I could delete the other account as I'm not using it for anything but I doubt that to be the issue.

ristomatti commented 8 months ago

Actually the error is exactly the same as reported on #21, a regression perhaps?

Jonatha1983 commented 8 months ago

Probably.

I ll investigate during the weekend.

ristomatti commented 8 months ago

The VSCode extension I've linked to previously seems to still work https://github.com/ankitbko/vscode-pull-request-azdo. To login, I filled int the organization URL, project name and a PAT token. Apparently nowadays it supports Azure account as well. It's open source, perhaps you'd get hints there?

Jonatha1983 commented 8 months ago

I would love to keep the login same as jetbrains GitHub and Gitlab plugins in which one don't need to give any other info beside a PAT.

Azure has much more options and not a consistent API for fetching the user id ( they migrate to user descriptor) + service / server / service with legacy url and so on... so it is a bigger challenge to test all the scenarios.

I ll take a look on vcs code and if I ll not find a better solution I will ask the user for more info when logging in.

ristomatti commented 8 months ago

I can only imagine. Maybe that is the reason why Microsoft has not implemented one by themselves, even for VSCode. If that was not odd enough, the AZDo plugin repo seems to be forked from a VSCode GitHub pull request plugin... by Microsoft!

I don't find any issue in asking for more info, especially if it would help reduce the permissions required. At least this AZDo plugin has gotten away with much less. I haven't checked if it offers the same set of features though. I installed it just to see if it works and to confirm my account has the required permissions. I'd rather review PR's on DevOps web interface. 🙂

Jonatha1983 commented 8 months ago

@ristomatti Hi sorry for the delay.

Can you try this EAP version 2024.1.28

https://plugins.jetbrains.com/plugin/22319-azd/edit/versions/eap

Note you will have to remove the old user if you have one - I tested this multiple time with different scenario I am pretty sure it will work well for you.

Please let me know.

Thanks

ristomatti commented 8 months ago

I can't seem to be able to re-add the user account with the same token:

image

It would be helpful to list the required permissions with the names shown on the DevOps dialog BTw. This is how I've set them:

image image image image image

Jonatha1983 commented 8 months ago

Need to add to the url the organization name - sorry forgot to mention that

Jonatha1983 commented 8 months ago

And no need access to all organization now

Jonatha1983 commented 8 months ago

It should have been added automatically- did you removed it from the url text field or was it like that?

ristomatti commented 8 months ago

Sorry forgot to report back yesterday after testing. Adding the organization name in the URL was indeed what was needed.

It should have been added automatically- did you removed it from the url text field or was it like that?

Do you mean if the organization name was automatically added on the URL after entering the PAT? If so, it did not. I'll try removing the all org access and see if that does it.

ristomatti commented 8 months ago

Nope it didn't update the URL. Manually updating the URL is fine but the "Server" label is then misleading. I don't have any good suggestions though, "DevOps URL"?

A separate input field would be be more obvious. Event a hint text with example URL's the plugin will accept below the field could do it as well.

P.S. Is there a keyboard shortcut to add an inline comment?