Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

Commit 0444c42

Browse files
dryajovdaviddias
authored andcommitted
fix: config handler should check if value is null (#1134)
1 parent 5d61d93 commit 0444c42

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/http/api/resources/config.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,9 @@ exports.getOrSet = {
5959
const value = request.pre.args.value
6060
const ipfs = request.server.app.ipfs
6161

62-
if (typeof value === 'object' &&
63-
value.type === 'Buffer') {
62+
// check that value exists - typeof null === 'object'
63+
if (value && (typeof value === 'object' &&
64+
value.type === 'Buffer')) {
6465
return reply({
6566
Message: 'Invalid value type',
6667
Code: 0

test/cli/config.js

+6
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ describe('config', () => runOnAndOff((thing) => {
4545
})
4646
})
4747

48+
it('set a config key with null', () => {
49+
return ipfs('config foo null --json').then((out) => {
50+
expect(updatedConfig().foo).to.equal(null)
51+
})
52+
})
53+
4854
it('set a config key with json', () => {
4955
return ipfs('config foo {"bar":0} --json').then((out) => {
5056
expect(updatedConfig().foo).to.deep.equal({ bar: 0 })

0 commit comments

Comments
 (0)