Skip to content

Commit 705b1ef

Browse files
committed
feat: add deprecation on explain
1 parent 00f8d4c commit 705b1ef

File tree

4 files changed

+58
-1
lines changed

4 files changed

+58
-1
lines changed

DEPRECATIONS.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ The following is a list of deprecations, according to the [Deprecation Policy](h
1414
| DEPPS8 | Login with expired 3rd party authentication token defaults to `false` | [#7079](https://github.com/parse-community/parse-server/pull/7079) | 5.3.0 (2022) | 7.0.0 (2024) | removed | - |
1515
| DEPPS9 | Rename LiveQuery `fields` option to `keys` | [#8389](https://github.com/parse-community/parse-server/issues/8389) | 6.0.0 (2023) | 7.0.0 (2024) | removed | - |
1616
| DEPPS10 | Encode `Parse.Object` in Cloud Function and remove option `encodeParseObjectInCloudFunction` | [#8634](https://github.com/parse-community/parse-server/issues/8634) | 6.2.0 (2023) | 9.0.0 (2026) | deprecated | - |
17-
| DEPPS11 | Replace `PublicAPIRouter` with `PagesRouter` | [#7625](https://github.com/parse-community/parse-server/issues/7625) | 8.0.0 (2025) | 9.0.0 (2026) | deprecated | - |
17+
| DEPPS11 | Replace `PublicAPIRouter` with `PagesRouter` | [#7625](https://github.com/parse-community/parse-server/issues/7625) | 8.0.0 (2025) | 9.0.0 (2026)
18+
| DEPPS12 | Restrict `explain` query parameter to master key | [#7519](https://github.com/parse-community/parse-server/issues/7519) | 8.3.0 (2025) | 9.0.0 (2027) | deprecated | | deprecated | - |
1819

1920
[i_deprecation]: ## "The version and date of the deprecation."
2021
[i_removal]: ## "The version and date of the planned removal."

changelogs/CHANGELOG_alpha.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# [8.3.0-alpha.13](https://github.com/parse-community/parse-server/compare/8.3.0-alpha.12...8.3.0-alpha.13) (2025-10-25)
2+
3+
### Features
4+
5+
- Deprecation DEPPS12: `explain` query parameter without master key ([#7519](https://github.com/parse-community/parse-server/issues/7519)) ([DEPPS12](https://github.com/parse-community/parse-server/blob/alpha/DEPRECATIONS.md#depps12))
6+
17
# [8.3.0-alpha.12](https://github.com/parse-community/parse-server/compare/8.3.0-alpha.11...8.3.0-alpha.12) (2025-10-25)
28

39

spec/ParseQuery.spec.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5384,4 +5384,40 @@ describe('Parse.Query testing', () => {
53845384
expect(query1.length).toEqual(1);
53855385
});
53865386
});
5387+
5388+
it_id('DEPPS12')(it_only_db('mongo'))(
5389+
'throws error when using explain without master key',
5390+
async () => {
5391+
const obj = new TestObject({ foo: 'bar' });
5392+
await obj.save();
5393+
5394+
const spyLogRuntimeDeprecation = spyOn(Deprecator, 'logRuntimeDeprecation');
5395+
5396+
// Test that explain without master key throws an error
5397+
const query = new Parse.Query(TestObject);
5398+
query.explain();
5399+
5400+
try {
5401+
await query.find();
5402+
5403+
expect(spyLogRuntimeDeprecation).toHaveBeenCalledTimes(1);
5404+
expect(spyLogRuntimeDeprecation).toHaveBeenCalledWith({
5405+
usage: 'Using the explain query parameter without the master key',
5406+
});
5407+
// fail('Should have thrown an error');
5408+
} catch (error) {
5409+
// Uncomment this after the Deprecation DEPPS12
5410+
// expect(error.code).toEqual(Parse.Error.INVALID_QUERY);
5411+
// expect(error.message).toEqual('Using the explain query parameter without the master key');
5412+
}
5413+
5414+
// Test that explain with master key works fine
5415+
const queryWithMasterKey = new Parse.Query(TestObject);
5416+
queryWithMasterKey.explain();
5417+
const result = await queryWithMasterKey.find({ useMasterKey: true });
5418+
5419+
// Should return explain result (not throw error)
5420+
expect(result).toBeDefined();
5421+
}
5422+
);
53875423
});

src/rest.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ var RestQuery = require('./RestQuery');
1313
var RestWrite = require('./RestWrite');
1414
var triggers = require('./triggers');
1515
const { enforceRoleSecurity } = require('./SharedRest');
16+
const Deprecator = require('./Deprecator/Deprecator');
1617

1718
function checkTriggers(className, config, types) {
1819
return types.some(triggerType => {
@@ -35,6 +36,19 @@ async function runFindTriggers(
3536
) {
3637
const { isGet } = options;
3738

39+
if (restOptions && restOptions.explain && !auth.isMaster) {
40+
// After the Deprecation DEPPS12 uncomment this to throw an error
41+
// throw new Parse.Error(
42+
// Parse.Error.INVALID_QUERY,
43+
// 'Using the explain query parameter without the master key'
44+
// );
45+
46+
// Deprecation DEPPS12
47+
Deprecator.logRuntimeDeprecation({
48+
usage: 'Using the explain query parameter without the master key',
49+
});
50+
}
51+
3852
// Run beforeFind trigger - may modify query or return objects directly
3953
const result = await triggers.maybeRunQueryTrigger(
4054
triggers.Types.beforeFind,

0 commit comments

Comments
 (0)