From 6ed52f37ccfb26df2d4dc72c4c9bdb0002e46aa5 Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Mon, 9 Jan 2023 17:30:49 -0500 Subject: [PATCH] Only fix stub if we actually found one. --- server/homebrew.api.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/server/homebrew.api.js b/server/homebrew.api.js index b4339011f..56bbb15f4 100644 --- a/server/homebrew.api.js +++ b/server/homebrew.api.js @@ -47,7 +47,7 @@ const api = { console.warn(err); } }); - stub = stub?.toObject() || {}; + stub = stub?.toObject(); // If there is a google id, try to find the google brew if(!stubOnly && (googleId || stub?.googleId)) { @@ -77,9 +77,11 @@ If you believe you should have access to this brew, ask the file owner to invite } // Clean up brew: fill in missing fields with defaults / fix old invalid values - stub.tags = stub.tags || undefined; // Clear empty strings - stub.renderer = stub.renderer || undefined; // Clear empty strings - stub = _.defaults(stub, DEFAULT_BREW_LOAD); // Fill in blank fields + if(stub) { + stub.tags = stub.tags || undefined; // Clear empty strings + stub.renderer = stub.renderer || undefined; // Clear empty strings + stub = _.defaults(stub, DEFAULT_BREW_LOAD); // Fill in blank fields + } req.brew = stub; next();