Skip to content

Commit 91031f1

Browse files
fix(variables): passing an empty variable value should throw an error. fixes #305 (#306)
1 parent 934ad84 commit 91031f1

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/cloudmanager-helpers.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ function createKeyValueObjectFromFlag (flag) {
8282
tempObj[flag[i]] = flag[i + 1]
8383
}
8484
}
85+
if (Object.values(tempObj).filter(v => v === '').length) {
86+
throw new Error('Blank variable values are not allowed. Use the proper flag if you intend to delete a variable.')
87+
}
8588
return tempObj
8689
} else {
8790
throw (new Error('Please provide correct values for flags'))

test/commands/pipeline/set-variables.test.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,19 @@ test('set-pipeline-variables - bad variable flag', async () => {
5656
await expect(runResult).rejects.toEqual(new Error('Please provide correct values for flags'))
5757
})
5858

59+
test('set-pipeline-variables - empty variable flag', async () => {
60+
setCurrentOrgId('good')
61+
setStore({
62+
cloudmanager_programid: '5',
63+
})
64+
65+
expect.assertions(2)
66+
67+
const runResult = SetPipelineVariablesCommand.run(['8', '--variable', 'foo', ''])
68+
await expect(runResult instanceof Promise).toBeTruthy()
69+
await expect(runResult).rejects.toEqual(new Error('Blank variable values are not allowed. Use the proper flag if you intend to delete a variable.'))
70+
})
71+
5972
test('set-pipeline-variables - bad secret flag', async () => {
6073
setCurrentOrgId('good')
6174
setStore({

0 commit comments

Comments
 (0)