Skip to content

Commit e698f61

Browse files
committed
Handle null param in cloud code. Fixes #1472 (#1746)
1 parent e60901d commit e698f61

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

spec/ParseAPI.spec.js

+16
Original file line numberDiff line numberDiff line change
@@ -1119,6 +1119,22 @@ describe('miscellaneous', function() {
11191119
});
11201120
});
11211121

1122+
it('can handle null params in cloud functions (regression test for #1742)', done => {
1123+
Parse.Cloud.define('func', (request, response) => {
1124+
expect(request.params.nullParam).toEqual(null);
1125+
response.success('yay');
1126+
});
1127+
1128+
Parse.Cloud.run('func', {nullParam: null})
1129+
.then(() => {
1130+
Parse.Cloud._removeHook('Functions', 'func');
1131+
done()
1132+
}, e => {
1133+
fail('cloud code call failed');
1134+
done();
1135+
});
1136+
});
1137+
11221138
it('fails on invalid client key', done => {
11231139
var headers = {
11241140
'Content-Type': 'application/octet-stream',

src/Routers/FunctionsRouter.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export class FunctionsRouter extends PromiseRouter {
3636
for (var key in params) {
3737
if (params.hasOwnProperty(key)) {
3838
var value = params[key];
39-
if (value.__type == 'Date') {
39+
if (value && value.__type == 'Date') {
4040
params[key] = new Date(value.iso);
4141
}
4242
}

0 commit comments

Comments
 (0)