From 4e60a7910b26a81c72cea7e25e440248d6d8dd99 Mon Sep 17 00:00:00 2001 From: Ankur Dubey Date: Thu, 29 Oct 2026 17:40:32 +0530 Subject: [PATCH] fix: unsupported __op value in a write request returns HTTP 500 --- spec/ParseAPI.spec.js | 23 +++++++++++++++++++++++ src/Controllers/SchemaController.js | 5 ++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/spec/ParseAPI.spec.js b/spec/ParseAPI.spec.js index 963c654f7f..21e3d4d0f3 100644 --- a/spec/ParseAPI.spec.js +++ b/spec/ParseAPI.spec.js @@ -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', () => { diff --git a/src/Controllers/SchemaController.js b/src/Controllers/SchemaController.js index b178ac7850..ac78240141 100644 --- a/src/Controllers/SchemaController.js +++ b/src/Controllers/SchemaController.js @@ -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';