Incorrect variable encoding/decoding when using setVariable + getInput
JiriKovar opened this issue · 7 comments
Environment
azure-pipelines-task-lib version: 2.10.1
Issue Description
When setting a variable with data that contains any of these:
The data gets encoded, but is not decoded upon retrieval.Expected behaviour
I can retrieve the same data I stored.
Actual behaviour
The data is encoded upon set, but is not decoded upon get.
Steps to reproduce
- I'm setting a secret via
azure-pipelines-task-lib/node/task.ts
Line 161 in 40b9763
- The secret contains JSON which contains URL with encoded query string. Please notice the %2F. Sample:
{ "webhooks": [ { "method": "POST", "url": "https://prod-83.westeurope.logic.azure.com:443/workflows/544685476486354/triggers/manual/paths/invoke?api-version=2016-06-01\u0026sp=%2Ftriggers%2Fmanual%2Frun\u0026sv=1.0\u0026sig=HEKSopljgflJUIJPjljpuipkj" } ] }}
- The value is later passed as input to another task and retrieved via
azure-pipelines-task-lib/node/task.ts
Line 218 in 40b9763
- The retrieved value looks like this (please notice the %252F ):
{ "webhooks": [ { "method": "POST", "url": "https://prod-83.westeurope.logic.azure.com:443/workflows/544685476486354/triggers/manual/paths/invoke?api-version=2016-06-01\u0026sp=%252Ftriggers%252Fmanual%252Frun\u0026sv=1.0\u0026sig=HEKSopljgflJUIJPjljpuipkj" } ] }
- I'm afraid that it's because of this and there is nothing I can do about it:
Just got the same issue, it's really troublesome and as you said not much we can do about it
@JiriKovar Do you have a workaround? it's screwing our secrets since % becomes %25
So currently we manually change them back, but its defeating the point of automation...
I'm probably missing something, but I can't seem to repro this. Admittedly my attempt at a repro is simplified and that could explain it - hoping you'll spot what I'm doing wrong. I did also attempt with a secret variable which didn't seem to change anything.
pool: { vmImage: ubuntu-latest }
steps:
- checkout: none
- script: |
echo "##vso[task.setVariable variable=foo]sp=%2Ftriggers%2Fautomatic"
displayName: set
- task: Bash@3
inputs:
targetType: inline
script: echo $(foo)
displayName: show
yields:
This should be fixed by microsoft/azure-pipelines-agent#3152. I think the issue only manifests when you get the input via an old version of the task-lib or you don't use the task-lib at all to retrieve it
@damccorm I confirm that the issue was when using task lib and simply doing tl.setVariable("foo", "dummy%", true)
Then the value of foo would become dummy%25
Could you tell us in which version of task lib the issue is solved? From what I see your PR was merged 10d ago. See:
Thanks
@molinch that pr was on our agent repo - so it will roll out automatically. It will be turned off by default initially, but eventually fully enabled (see https://github.com/microsoft/azure-pipelines-agent/blob/master/docs/design/percentEncoding.md)
This should be fixed