Skip to content
This repository has been archived by the owner on Dec 31, 2024. It is now read-only.

Don't return stack errors to client #613

Merged
merged 2 commits into from
Sep 14, 2021
Merged
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
9 changes: 7 additions & 2 deletions src/app.hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const convertVerifiedToBoolean = () => context => {
return context;
};

const changeMongoErrors = () => context => {
const parseErrors = () => context => {
// verified field is boolean in Trace, Campaign and Community so for getting this filter
// in query string we should cast it to boolean here
if (context.error.message.includes('Invalid query parameter')) {
Expand All @@ -69,6 +69,11 @@ const changeMongoErrors = () => context => {
logger.info('Mongo error in feathers call', context.error);
throw new errors.BadRequest(errorMessages.INVALID_INPUT_DATA);
}
if (context.error.stack && context.error.type !== 'FeathersError') {
// Should not return stack error to client when error is not instance of Feathers error
logger.info('Error with stack', context.error);
throw new errors.GeneralError();
}
return context;
};

Expand Down Expand Up @@ -123,7 +128,7 @@ module.exports = {
},

error: {
all: [responseLoggerHook(), changeMongoErrors()],
all: [responseLoggerHook(), parseErrors()],
find: [],
get: [],
create: [],
Expand Down