Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions spec/ParseAPI.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2470,6 +2470,29 @@ describe('miscellaneous', () => {
}
);
});

it('rejects an unsupported __op with a client error', async () => {
const headers = {
'Content-Type': 'application/json',
'X-Parse-Application-Id': 'test',
'X-Parse-Master-Key': 'test',
};
const obj = new Parse.Object('Thing');
await obj.save();
for (const op of [{ __op: 'SetOnInsert', amount: 1 }, { __op: 'Foo' }]) {
for (const [method, url] of [
['POST', 'http://localhost:8378/1/classes/Thing'],
['PUT', `http://localhost:8378/1/classes/Thing/${obj.id}`],
]) {
const response = await request({ method, url, headers, body: { counter: op } }).catch(
error => error
);
expect(response.status).toBe(400);
expect(response.data.code).toBe(Parse.Error.COMMAND_UNAVAILABLE);
expect(response.data.error).toBe(`The ${op.__op} operator is not supported yet.`);
}
}
});
});

describe_only_db('mongo')('legacy _acl', () => {
Expand Down
5 changes: 4 additions & 1 deletion src/Controllers/SchemaController.js
Original file line number Diff line number Diff line change
Expand Up @@ -1709,7 +1709,10 @@ function getObjectType(obj): ?(SchemaField | string) {
case 'Batch':
return getObjectType(obj.ops[0]);
default:
throw 'unexpected op: ' + obj.__op;
throw new Parse.Error(
Parse.Error.COMMAND_UNAVAILABLE,
`The ${obj.__op} operator is not supported yet.`
);
}
}
return 'Object';
Expand Down