Skip to content

Commit 19c0025

Browse files
committed
fix: feedbacks
1 parent a0a32ee commit 19c0025

File tree

5 files changed

+21
-21
lines changed

5 files changed

+21
-21
lines changed

spec/Utils.spec.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,8 @@ describe('Utils', () => {
176176
});
177177

178178
describe('createSanitizedError', () => {
179-
it('should return "Permission denied" when disableSanitizeError is false or undefined', () => {
180-
const config = { disableSanitizeError: false };
179+
it('should return "Permission denied" when enableSanitizedErrorResponse is false or undefined', () => {
180+
const config = { enableSanitizedErrorResponse: true };
181181
const error = createSanitizedError(Parse.Error.OPERATION_FORBIDDEN, 'Detailed error message', config);
182182
expect(error.message).toBe('Permission denied');
183183
});
@@ -187,16 +187,16 @@ describe('Utils', () => {
187187
expect(error.message).toBe('Permission denied');
188188
});
189189

190-
it('should return the detailed message when disableSanitizeError is true', () => {
191-
const config = { disableSanitizeError: true };
190+
it('should return the detailed message when enableSanitizedErrorResponse is true', () => {
191+
const config = { enableSanitizedErrorResponse: false };
192192
const error = createSanitizedError(Parse.Error.OPERATION_FORBIDDEN, 'Detailed error message', config);
193193
expect(error.message).toBe('Detailed error message');
194194
});
195195
});
196196

197197
describe('createSanitizedHttpError', () => {
198-
it('should return "Permission denied" when disableSanitizeError is false or undefined', () => {
199-
const config = { disableSanitizeError: false };
198+
it('should return "Permission denied" when enableSanitizedErrorResponse is false or undefined', () => {
199+
const config = { enableSanitizedErrorResponse: true };
200200
const error = createSanitizedHttpError(403, 'Detailed error message', config);
201201
expect(error.message).toBe('Permission denied');
202202
});
@@ -206,8 +206,8 @@ describe('Utils', () => {
206206
expect(error.message).toBe('Permission denied');
207207
});
208208

209-
it('should return the detailed message when disableSanitizeError is true', () => {
210-
const config = { disableSanitizeError: true };
209+
it('should return the detailed message when enableSanitizedErrorResponse is true', () => {
210+
const config = { enableSanitizedErrorResponse: false };
211211
const error = createSanitizedHttpError(403, 'Detailed error message', config);
212212
expect(error.message).toBe('Detailed error message');
213213
});

src/Error.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function createSanitizedError(errorCode, detailedMessage, config) {
1616
defaultLogger.error(detailedMessage);
1717
}
1818

19-
return new Parse.Error(errorCode, config?.disableSanitizeError ? detailedMessage : 'Permission denied');
19+
return new Parse.Error(errorCode, config?.enableSanitizedErrorResponse !== false ? 'Permission denied' : detailedMessage);
2020
}
2121

2222
/**
@@ -37,7 +37,7 @@ function createSanitizedHttpError(statusCode, detailedMessage, config) {
3737

3838
const error = new Error();
3939
error.status = statusCode;
40-
error.message = config?.disableSanitizeError ? detailedMessage : 'Permission denied';
40+
error.message = config?.enableSanitizedErrorResponse !== false ? 'Permission denied' : detailedMessage;
4141
return error;
4242
}
4343

src/Options/Definitions.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -199,13 +199,6 @@ module.exports.ParseServerOptions = {
199199
action: parsers.booleanParser,
200200
default: true,
201201
},
202-
disableSanitizeError: {
203-
env: 'PARSE_SERVER_DISABLE_SANITIZE_ERROR',
204-
help:
205-
'If true, disables sanitizing errors and returns the detailed message instead of "Permission denied".',
206-
action: parsers.booleanParser,
207-
default: false,
208-
},
209202
dotNetKey: {
210203
env: 'PARSE_SERVER_DOT_NET_KEY',
211204
help: 'Key for Unity and .Net SDK',
@@ -254,6 +247,13 @@ module.exports.ParseServerOptions = {
254247
action: parsers.booleanParser,
255248
default: true,
256249
},
250+
enableSanitizedErrorResponse: {
251+
env: 'PARSE_SERVER_ENABLE_SANITIZED_ERROR_RESPONSE',
252+
help:
253+
'If set to `true`, error details are removed from error messages in responses to client requests, and instead a generic error message is sent. Default is `true`.',
254+
action: parsers.booleanParser,
255+
default: true,
256+
},
257257
encodeParseObjectInCloudFunction: {
258258
env: 'PARSE_SERVER_ENCODE_PARSE_OBJECT_IN_CLOUD_FUNCTION',
259259
help:

src/Options/docs.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Options/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -347,9 +347,9 @@ export interface ParseServerOptions {
347347
rateLimit: ?(RateLimitOptions[]);
348348
/* Options to customize the request context using inversion of control/dependency injection.*/
349349
requestContextMiddleware: ?(req: any, res: any, next: any) => void;
350-
/* If true, disables sanitizing errors and returns the detailed message instead of "Permission denied".
351-
:DEFAULT: false */
352-
disableSanitizeError: ?boolean;
350+
/* If set to `true`, error details are removed from error messages in responses to client requests, and instead a generic error message is sent. Default is `true`.
351+
:DEFAULT: true */
352+
enableSanitizedErrorResponse: ?boolean;
353353
}
354354

355355
export interface RateLimitOptions {

0 commit comments

Comments
 (0)