huserben / TfsExtensions

Extensions for TFS 2015+ such as custom Widgets (require TFS 2017) and Build Tasks
MIT License
45 stars 22 forks source link

Double encoding of URL with space in collection name #12

Closed viperx77 closed 7 years ago

viperx77 commented 7 years ago

The collection name is "Out Patient"

notice that the %20 has been encoded as %2520

2017-06-26T20:05:44.8646671Z ##[debug]GET http://usdbalrwd1mstf1:8080/tfs/Out%2520Patient/eCareCoordinator/_apis/build/definitions?api-version=2.0&name=Test Child with 0-byte payload 2017-06-26T20:05:44.9427924Z ##[error]System.Net.WebException: The remote server returned an error: (404) Not Found. 2017-06-26T20:05:44.9427924Z ##[debug]Processed: ##vso[task.logissue type=error;]System.Net.WebException: The remote server returned an error: (404) Not Found. 2017-06-26T20:05:44.9427924Z at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.GetResponse(WebRequest request) 2017-06-26T20:05:44.9427924Z at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.ProcessRecord() 2017-06-26T20:05:44.9427924Z ##[error]System.Management.Automation.RuntimeException: Cannot index into a null array. 2017-06-26T20:05:44.9427924Z ##[debug]Processed: ##vso[task.logissue type=error;]System.Management.Automation.RuntimeException: Cannot index into a null array. 2017-06-26T20:05:44.9427924Z at CallSite.Target(Closure , CallSite , Object , Int32 ) 2017-06-26T20:05:44.9427924Z at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1) 2017-06-26T20:05:44.9427924Z at System.Management.Automation.Interpreter.DynamicInstruction`3.Run(InterpretedFrame frame) 2017-06-26T20:05:44.9427924Z at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame) 2017-06-26T20:05:44.9427924Z Queue new Build for definition Test Child on http://usdbalrwd1mstf1:8080/tfs/Out%20Patient/eCareCoordinator/_apis/build/builds?api-version=2.0 2017-06-26T20:05:44.9427924Z { definition: { id: }, sourceBranch: "$/eCareCoordinator/main2/src/Client", requestedFor: { id: "d1430d16-33c4-4156-a6ad-5ea70767cf4d"}} 2017-06-26T20:05:44.9427924Z ##[debug]POST http://usdbalrwd1mstf1:8080/tfs/Out%2520Patient/eCareCoordinator/_apis/build/builds?api-version=2.0 with -1-byte payload 2017-06-26T20:05:44.9584199Z ##[error]System.Net.WebException: The remote server returned an error: (404) Not Found. 2017-06-26T20:05:44.9584199Z ##[debug]Processed: ##vso[task.logissue type=error;]System.Net.WebException: The remote server returned an error: (404) Not Found. 2017-06-26T20:05:44.9584199Z at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.GetResponse(WebRequest request) 2017-06-26T20:05:44.9584199Z at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.ProcessRecord() 2017-06-26T20:05:44.9584199Z ##[debug]POST http://usdbalrwd1mstf1:8080/tfs/Out%2520Patient/eCareCoordinator/_apis/build/builds?api-version=2.0 with 0-byte payload 2017-06-26T20:05:44.9584199Z ##[error]System.Net.WebException: The remote server returned an error: (404) Not Found. 2017-06-26T20:05:44.9584199Z ##[debug]Processed: ##vso[task.logissue type=error;]System.Net.WebException: The remote server returned an error: (404) Not Found. 2017-06-26T20:05:44.9584199Z at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.GetResponse(WebRequest request) 2017-06-26T20:05:44.9740394Z at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.ProcessRecord()

huserben commented 7 years ago

Hi @viperx77

thanks for the input, I will have a look into the problem and will try to fix it as soon as possible.

huserben commented 7 years ago

Hi

I tried to reproduce this problem, but i could not see any problem. I right now just have a default collection to test (VSTS only works with defaultcollection) but i tried with a project that contains spaces and there was no issue in the escaping. Can you provide more details on your configuration (Settings of the Task, where do you run it on (Git or TFSVC, Hosted or non hosted build agents etc.) so that i can try to figure out the problem

viperx77 commented 7 years ago

TFSVC, non hosted build agent. You saw the log so not sure what else I can provide. I'm glad to do what I can to help.

On Tue, Jun 27, 2017 at 4:07 PM Benj Huser notifications@github.com wrote:

Hi

I tried to reproduce this problem, but i could not see any problem. I right now just have a default collection to test (VSTS only works with defaultcollection) but i tried with a project that contains spaces and there was no issue in the escaping. Can you provide more details on your configuration (Settings of the Task, where do you run it on (Git or TFSVC, Hosted or non hosted build agents etc.) so that i can try to figure out the problem

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/huserben/TfsExtensions/issues/12#issuecomment-311470251, or mute the thread https://github.com/notifications/unsubscribe-auth/AAHZHiiGfRiBxKxX0_L6ROLLKn1P474pks5sIWEUgaJpZM4OGg4L .

huserben commented 7 years ago

So I tried locally by just running the PowerShell script to recreate the problem by debugging when specifying your TFS Adress (http://usdbalrwd1mstf1:8080/tfs/Out Patient/eCareCoordinator) to see what happens. As you can see in the attached picture, it gets escaped correctly (meaning just adds a "%20" instead of the space).

debugging_issue

What version of the Task are you using? And how did you configure the task. Maybe a screenshot of the BasicConfiguration section of the task could shed some light. I checked for the "%2025" that was used instead of the "%20" and found this post on SO. Is it possible that you specified the URL already encoded?

huserben commented 7 years ago

I added now the handling for when we already get an encoded string so we do not "double-encode" it. Can you try with the newest version and let me know if it works.

Anyhow I would still be interested in your configuration of the task so I can fully understand how we got the encoded string in the first place :-)

viperx77 commented 7 years ago

I will have to check at work. It maybe a few days before I can get back. Thanks for looking into it.

huserben commented 7 years ago

Hi @viperx77 any update on this issue? :-)

viperx77 commented 7 years ago

Good news. It worked.

Path to Server: http://usdbalrwd1mstf1.code1.emi.philips.com:8080/tfs/Out%20Patient/eCareCoordinator Using Default Credentials Build shall be triggered for same user that triggered current build: Mark Lindell Using same branch as source version: $/eCareCoordinator/dev/Firefly/build/build-projects Build In Queue Condition is not enabled Dependant Build Condition is not enabled Dependant on Failed Build Condition is not enabled Add FireFly DevTools to list of Builds to trigger Queue new Build for definition FireFly DevTools on http://usdbalrwd1mstf1.code1.emi.philips.com:8080/tfs/Out%20Patient/eCareCoordinator/_apis/build/builds?api-version=2.0 { definition: { id: 155 }, sourceBranch: "$/eCareCoordinator/dev/Firefly/build/build-projects", requestedFor: { id: "d1430d16-33c4-4156-a6ad-5ea70767cf4d"}} Queued new Build for Definition FireFly DevTools with ID: 36688

On Wed, Jul 5, 2017 at 11:32 AM Benj Huser notifications@github.com wrote:

Hi @viperx77 https://github.com/viperx77 any update on this issue? :-)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/huserben/TfsExtensions/issues/12#issuecomment-313139288, or mute the thread https://github.com/notifications/unsubscribe-auth/AAHZHhixtlTmwrNbYpkqx73jF1aClRk4ks5sK6yIgaJpZM4OGg4L .

huserben commented 7 years ago

Ok cool, so I will close this issue then.

Thanks for reporting this bug and please open a new issue if you find another bug or you have a change- or feature request.