Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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