URLQuery.parse fails parsing when = sign in parameter value
Hi!
I believe I have found a problem with parsing query part of URL In latest release available on github: https://github.com/Azure/ms-rest-js/blob/abc4f8f58ef1ac999315877eaf740c2bd0eddcbe/lib/url.ts#L71
Short context: I am trying to receive second page of my scale set virtual machines using following command:
computeClient.virtualMachineScaleSetVMs.listNext(`https://management.azure.com:443/subscriptions/1111111-1111-1111-1111-1111111111/resourceGroups/ae-workers/providers/Microsoft.Compute/virtualMachineScaleSets/ae-workers-scale-1000/virtualMachines?api-version=2020-06-01&$skiptoken=ODIzZnNkdi01YXNjLTEzc2EtMTI1NS1jYTNhc2QxMmRhMyEvU3Vic2NyaXB0aW9ucy8xMTExMTEtMTExMS0xMTExLTExMTEtMTExMTExMTExL1Jlc291cmNlR3JvdXBzL0FFLVdPUktFUlMvVk1TY2FsZVNldHMvQUUtV09SS0VSUy1TQ0FMRS0xMDAwL1ZNcy8xNDMz==`);
Parameter is the nextLink, which I received from previous execution of list method.
As you can see returned skiptoken is base64 encoded data with '==' signs at the end. When executing computeClient.virtualMachineScaleSetVMs.listNext URLQuery.parse is executed as well.
We can find there something:
case "ParameterValue":
switch (currentCharacter) {
case "=":
parameterName = "";
parameterValue = "";
currentState = "Invalid";
break;
I believe that this part should be removed - query param value can contain '=' sign. Please tell me if I'm wrong.
My $skiptoken is not correctly parsed and in result I cannot get second page for my scale set virtual machines.
Best, Krzysztof Kamiński
Thanks for reporting @kkaminski-github We will take a look and get back in the first week of Jan 2021
Thanks @ramya-rao-a!
I will track this issue to answer any additional questions if they appear ;-)
@kkaminski-github thanks for reporting this issue and doing the initial investigation. I'm going to be looking at this later today and will update you as soon as I have more information
Quick update, I got a local repro, currently investigating possible solutions
@joheredi thanks for your update. Let me know If I can help somehow ;-)
@kkaminski-github I have a PR out to fix this in ms-rest-js. Which package is the one you were using when found this problem?
Sure!
From my code:
getScaleSetWorkers: async () => {
//TODO: UPGRADE @azure/ms-rest-js before publishing. https://github.com/Azure/ms-rest-js/issues/406
const result = [];
const scaleSetVms = await scaleSetManager.computeClient.virtualMachineScaleSetVMs.list(resourceGroupName, vmSsName);
result.push(...scaleSetVms);
let nextLinkToken = scaleSetVms.nextLink;
while(nextLinkToken){
const scaleSetVmsNext = await scaleSetManager.computeClient.virtualMachineScaleSetVMs.listNext(nextLinkToken);
result.push(...scaleSetVmsNext);
nextLinkToken = scaleSetVmsNext.nextLink
}
return result;
},
where scaleSetManager.computeClient = new ComputeManagementClient(credentials, subscriptionIdSCP); and const {ComputeManagementClient} = require("@azure/arm-compute");
Thanks @kkaminski-github! Is @azure/arm-compute the package you are using?
Yes - as written above ;-)
Thank you @joheredi for fixing the issue ;-)