edgafner / dorkag

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

URL with spaces causes IllegalArgumentException #53

Open Louis9902 opened 8 months ago

Louis9902 commented 8 months ago

Hello again, I have found another Problem when checking out Reviews, apparently something went wrong when using the URL to our TFS. I removed the URL but the Problem seems to be that there is an unescaped space in the URL. The git origin url has an escaped space at this position, so I dont know how the extension determins the URL.

AZDCopyLinkActionGroup#Update@ProjectViewPopup (com.gafner.plugin.azd.ui.action.AZDCopyLinkActionGroup), actionId=AZD.Copy.Link, text='Copy Link to AZD Repository'

java.lang.IllegalArgumentException: Illegal character in path at index 76: <URL-HERE>
    at java.base/java.net.URI.create(URI.java:906)
    at java.base/java.net.URI.resolve(URI.java:1089)
    at com.intellij.collaboration.util.URIUtilKt.resolveRelative(URIUtil.kt:66)
    at com.gafner.plugin.azd.api.AZDProjectCoordinates.getWebURI(AZDProjectCoordinates.kt:15)
    at git4idea.remote.hosting.action.HostedGitRepositoryReferenceUtil.findReferences(HostedGitRepositoryReferenceUtil.kt:119)
    at git4idea.remote.hosting.action.HostedGitRepositoryReferenceUtil.findReferences(HostedGitRepositoryReferenceUtil.kt:96)
    at git4idea.remote.hosting.action.GlobalHostedGitRepositoryReferenceActionGroup.findReferencesInFile(GlobalHostedGitRepositoryReferenceActionGroup.kt:51)
    at git4idea.remote.hosting.action.GlobalHostedGitRepositoryReferenceActionGroup.findReferences(GlobalHostedGitRepositoryReferenceActionGroup.kt:33)
    at git4idea.remote.hosting.action.HostedGitRepositoryReferenceActionGroup.update(HostedGitRepositoryReferenceActionGroup.kt:29)
    at com.intellij.openapi.actionSystem.ex.ActionUtil.lambda$performDumbAwareUpdate$0(ActionUtil.java:164)
    at com.intellij.openapi.actionSystem.ex.ActionUtil.performDumbAwareUpdate(ActionUtil.java:187)
    at com.intellij.openapi.actionSystem.impl.ActionUpdaterKt.doUpdate(ActionUpdater.kt:696)
    at com.intellij.openapi.actionSystem.impl.ActionUpdaterKt.access$doUpdate(ActionUpdater.kt:1)
    at com.intellij.openapi.actionSystem.impl.ActionUpdater$updateActionReal$success$1.invoke(ActionUpdater.kt:110)
    at com.intellij.openapi.actionSystem.impl.ActionUpdater$updateActionReal$success$1.invoke(ActionUpdater.kt:109)
    at com.intellij.openapi.actionSystem.impl.ActionUpdater$callAction$3$adjustedCall$1.invoke(ActionUpdater.kt:157)
    at com.intellij.openapi.application.rw.InternalReadAction.insideReadAction(InternalReadAction.kt:108)
    at com.intellij.openapi.application.rw.InternalReadAction.access$insideReadAction(InternalReadAction.kt:16)
    at com.intellij.openapi.application.rw.InternalReadAction$tryReadCancellable$2.invoke(InternalReadAction.kt:95)
    at com.intellij.openapi.application.rw.InternalReadAction$tryReadCancellable$2.invoke(InternalReadAction.kt:94)
    at com.intellij.openapi.application.rw.CancellableReadActionKt$cancellableReadActionInternal$1.invoke$lambda$1$lambda$0(cancellableReadAction.kt:38)
    at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:1075)
    at com.intellij.openapi.application.rw.CancellableReadActionKt$cancellableReadActionInternal$1.invoke$lambda$1(cancellableReadAction.kt:36)
    at com.intellij.openapi.progress.util.ProgressIndicatorUtilService.runActionAndCancelBeforeWrite(ProgressIndicatorUtilService.java:73)
    at com.intellij.openapi.progress.util.ProgressIndicatorUtils.runActionAndCancelBeforeWrite(ProgressIndicatorUtils.java:128)
    at com.intellij.openapi.application.rw.CancellableReadActionKt$cancellableReadActionInternal$1.invoke(cancellableReadAction.kt:34)
    at com.intellij.openapi.progress.CoroutinesKt.blockingContextInner(coroutines.kt:321)
    at com.intellij.openapi.progress.CoroutinesKt.blockingContext(coroutines.kt:310)
    at com.intellij.openapi.application.rw.CancellableReadActionKt.cancellableReadActionInternal(cancellableReadAction.kt:31)
    at com.intellij.openapi.application.rw.InternalReadAction.tryReadCancellable(InternalReadAction.kt:94)
    at com.intellij.openapi.application.rw.InternalReadAction.tryReadAction(InternalReadAction.kt:78)
    at com.intellij.openapi.application.rw.InternalReadAction.readLoop(InternalReadAction.kt:65)
    at com.intellij.openapi.application.rw.InternalReadAction.access$readLoop(InternalReadAction.kt:16)
    at com.intellij.openapi.application.rw.InternalReadAction$runReadAction$3.invokeSuspend(InternalReadAction.kt:36)
    at com.intellij.openapi.application.rw.InternalReadAction$runReadAction$3.invoke(InternalReadAction.kt)
    at com.intellij.openapi.application.rw.InternalReadAction$runReadAction$3.invoke(InternalReadAction.kt)
    at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:78)
    at kotlinx.coroutines.CoroutineScopeKt.coroutineScope(CoroutineScope.kt:264)
    at com.intellij.openapi.application.rw.InternalReadAction.runReadAction(InternalReadAction.kt:35)
    at com.intellij.openapi.application.rw.PlatformReadWriteActionSupport.executeReadAction(PlatformReadWriteActionSupport.kt:38)
    at com.intellij.openapi.application.ReadWriteActionSupport.executeReadAction$default(ReadWriteActionSupport.kt:15)
    at com.intellij.openapi.application.CoroutinesKt.constrainedReadActionUndispatched(coroutines.kt:82)
    at com.intellij.openapi.application.CoroutinesKt.readActionUndispatched(coroutines.kt:69)
    at com.intellij.openapi.actionSystem.impl.ActionUpdater.callAction(ActionUpdater.kt:740)
    at com.intellij.openapi.actionSystem.impl.ActionUpdater.callAction(ActionUpdater.kt:134)
    at com.intellij.openapi.actionSystem.impl.ActionUpdater.updateActionReal(ActionUpdater.kt:109)
    at com.intellij.openapi.actionSystem.impl.ActionUpdater.update(ActionUpdater.kt:531)
    at com.intellij.openapi.actionSystem.impl.ActionUpdater.access$update(ActionUpdater.kt:71)
    at com.intellij.openapi.actionSystem.impl.ActionUpdater$iterateGroupChildren$tree$1.invokeSuspend(ActionUpdater.kt:491)
    at com.intellij.openapi.actionSystem.impl.ActionUpdater$iterateGroupChildren$tree$1.invoke(ActionUpdater.kt)
    at com.intellij.openapi.actionSystem.impl.ActionUpdater$iterateGroupChildren$tree$1.invoke(ActionUpdater.kt)
    at com.intellij.openapi.actionSystem.impl.ActionUpdater$iterateGroupChildren$2.invokeSuspend(ActionUpdater.kt:512)
    at com.intellij.openapi.actionSystem.impl.ActionUpdater$iterateGroupChildren$2.invoke(ActionUpdater.kt)
    at com.intellij.openapi.actionSystem.impl.ActionUpdater$iterateGroupChildren$2.invoke(ActionUpdater.kt)
    at kotlinx.coroutines.flow.SafeFlow.collectSafely(Builders.kt:61)
    at kotlinx.coroutines.flow.AbstractFlow.collect(Flow.kt:230)
    at com.intellij.openapi.actionSystem.impl.ActionUpdater$iterateGroupChildren$$inlined$filter$1.collect(SafeCollector.common.kt:114)
    at kotlinx.coroutines.flow.FlowKt__CollectionKt.toCollection(Collection.kt:26)
    at kotlinx.coroutines.flow.FlowKt.toCollection(Unknown Source)
    at com.intellij.openapi.actionSystem.impl.ActionUpdater$UpdateSessionImpl$expandedChildren$1.invokeSuspend(ActionUpdater.kt:606)
    at com.intellij.openapi.actionSystem.impl.ActionUpdater$UpdateSessionImpl$expandedChildren$1.invoke(ActionUpdater.kt)
    at com.intellij.openapi.actionSystem.impl.ActionUpdater$UpdateSessionImpl$expandedChildren$1.invoke(ActionUpdater.kt)
    at com.intellij.openapi.actionSystem.impl.ActionUpdater$getSessionDataDeferred$2$1.invokeSuspend(ActionUpdater.kt:553)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108)
    at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:115)
    at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:103)
    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)
Caused by: java.net.URISyntaxException: Illegal character in path at index 76: https://bc-tfs.activedirectory.bissantz.de/tfs/DefaultCollection/DeltaMaster Add-Ons/_git/DeltaAppService
    at java.base/java.net.URI$Parser.fail(URI.java:2976)
    at java.base/java.net.URI$Parser.checkChars(URI.java:3147)
    at java.base/java.net.URI$Parser.parseHierarchical(URI.java:3229)
    at java.base/java.net.URI$Parser.parse(URI.java:3177)
    at java.base/java.net.URI.<init>(URI.java:623)
    at java.base/java.net.URI.create(URI.java:904)
    ... 70 more
Jonatha1983 commented 8 months ago

Hi @Louis9902

I will fix this in the upcoming release.

Thanks for reporting.

Jonatha1983 commented 8 months ago

Hi @Louis9902 Can you confirm this is fixed in 2024.1.23?

Louis9902 commented 8 months ago

Hey, this problem seems to be fixed to some extend. The url is now not creating errors anymore, but now the collection name is missing. So when I use the link in the PR Header (!) the the url opens the browser but shows me the not found / no access page, because the Collection name does not seem to be part of the used url.

Should I open a seperate issue?

Jonatha1983 commented 8 months ago

No i ll fix it in here

Jonatha1983 commented 7 months ago

@Louis9902 hi this EAP version should have a fix for the title url:

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

Also, it contains some major refactoring on how the plugin calculates the organization/collection, project, and repo.

If you can test it on your Azure DevOps Server before I release it to everyone, that would be great.

Thanks a lot.

Louis9902 commented 7 months ago

Okay, I tried it, but I have some more Issues. First I needed to re login because the Account had an URI with undefined scheme (The relogin worked, but maybe something for the release notes). grafik

The second Problem is a litte more compilcated, because now I can't see my pull requests any more. When I press the View Pull Request button, I get the following error:

Could not connect to repository https://<tfs-server>/tfs/DefaultCollection with account https://<tfs-server>/seubert HTTP Request Request GET https://<tfs-server>/tfs%2FDefaultCollection%2F_apis%2Fgit%2Frepositories%2FHostingRegistry?includeParent=true&api-version=6.0-preview.1 failed with status code 400 and response body: {"$id":"1","innerException":null,"message":"A project name is required in order to reference a Git repository by name.","typeName":"System.ArgumentException, mscorlib","typeKey":"ArgumentException","errorCode":0,"eventId":0}

The interseting thing is, that this repository (HostingRegistry), is a git submodule in the main repositzory, which I have checked out and opend with Rider. So I think there is something wrong with the origin selection, since I only have the submodule in the drop down list to select from. If you need more information please let me know.

Jonatha1983 commented 7 months ago

Thanks for the input will fix it today and will update

Jonatha1983 commented 7 months ago

@Louis9902 When you run git remote -vv on the root project IS the output of this format:

ssh://your-server-url:22/tfs/DefaultCollection/ProjectName/_git/RepoName
#OR
https://your-server-ur/tfs/DefaultCollection/ProjectName/_git/RepoName

?

Also, the same flow worked for you with the previous version, right?

Louis9902 commented 7 months ago

@Jonatha1983 The remote is a ssh remote. The workflow worked for me in the last version. But I must note that I also have a strage config, because the submodule it self is configured via https but since this does not work for me (setup from my company) I have added a uri rewrite to my global git config.

[url "ssh://git@my-server-url"]
  insteadOf = "https://my-server-url"

The my-server-url is only the hostname of the server, no subpath.

Jonatha1983 commented 7 months ago

@Louis9902 So when you type got remote -vv what is the output format?

Louis9902 commented 7 months ago

@Louis9902 So when you type got remote -vv what is the output format?

It's origin ssh://git@<domain>.de/tfs/DefaultCollection/<project with uri escaped space>/_git/<repo>

Jonatha1983 commented 7 months ago

Sorry for the number of questions, so the repo is not the sub module right?

Louis9902 commented 7 months ago

correct, the remote of the submodule does look different: origin ssh://git@<domain>.de/tfs/DefaultCollection/_git/<project>. I think this is because the repo and the project have the same name.

Jonatha1983 commented 7 months ago

Sorry I lost you.

When you type git remote --vv from the cloned submodule root folder

You get the first pattern: ssh://git@<domain>.de/tfs/DefaultCollection/<project with uri escaped space>/_git/<repo>

or the one in the last post without the repo?

Louis9902 commented 7 months ago

Okay sorry for the confusion:

- project (default)   -> ssh://git@<domain>.de/tfs/DefaultCollection/<project with uri escaped space>/_git/<repo>
  \ -- libs/submodule -> ssh://git@<domain>.de/tfs/DefaultCollection/_git/<project>

The submodule shows ssh but only because of my config rewrite. The .gitmodules file in the default repository has an https address.

Louis9902 commented 7 months ago

@Jonatha1983 Okay I think I figured out what the problem is. We have a Project (the git submodule) where the project is named exactly like the one repository in it. Let's call this project ProjA. So the url for cloning and the browser url looks somewhat like <host>/tfs/DefaultCollection/_git/ProjA. When we take a lokk at a url from a repository inside another project where the repo and the project are named differently and the project has multiple projects then the url looks like <host>/tfs/DefaultCollection/ProjA/_git/RepoA.

So here is what I tink happens. Your api url reloution only takes the origin as 'base' url for the api. But the short form where project and repository names are equal is not supported by the api. When I use the short from like https://<host>/tfs/DefaultCollection/_apis/git/repositories/ProjA?includeParent=true&api-version=6.0-preview.1 to make an api request it fails. But when I change the url to https://<host>/tfs/DefaultCollection/ProjA/_apis/git/repositories/ProjA?includeParent=true&api-version=6.0-preview.1 the request completes succesful.

The Rider UI shows me just the first origin because it errors out and nevery tries to resolve the other origins.

Hope this hels.

Jonatha1983 commented 7 months ago

What is the short form? Any documentation regarding this you can point me to?

Louis9902 commented 7 months ago

Not really, but i can see the same if I create a new project on dev.azure.com When created with the defaults there is only one repo with the same name as the project. Then the url in the browser is the same short format https://dev.azure.com/<org>/_git/test, where test is the repo and project name. The clone url is then https://<org>@dev.azure.com/<org>/test/_git/test. But aparently somebody at my company used the url from the browser, which seems to also work for cloning etc.