diff --git a/src/http/api/resources/config.js b/src/http/api/resources/config.js index fec1fea76e..eb0c1af9a3 100644 --- a/src/http/api/resources/config.js +++ b/src/http/api/resources/config.js @@ -59,8 +59,9 @@ exports.getOrSet = { const value = request.pre.args.value const ipfs = request.server.app.ipfs - if (typeof value === 'object' && - value.type === 'Buffer') { + // check that value exists - typeof null === 'object' + if (value && (typeof value === 'object' && + value.type === 'Buffer')) { return reply({ Message: 'Invalid value type', Code: 0 diff --git a/test/cli/config.js b/test/cli/config.js index 5f3e72c460..76d3c77f3d 100644 --- a/test/cli/config.js +++ b/test/cli/config.js @@ -45,6 +45,12 @@ describe('config', () => runOnAndOff((thing) => { }) }) + it('set a config key with null', () => { + return ipfs('config foo null --json').then((out) => { + expect(updatedConfig().foo).to.equal(null) + }) + }) + it('set a config key with json', () => { return ipfs('config foo {"bar":0} --json').then((out) => { expect(updatedConfig().foo).to.deep.equal({ bar: 0 })