diff --git a/server/homebrew.api.js b/server/homebrew.api.js index bb0ab5e75..84f639a4d 100644 --- a/server/homebrew.api.js +++ b/server/homebrew.api.js @@ -357,7 +357,17 @@ const api = { let brew = _.assign(brewFromServer, brewFromClient); brew.title = brew.title.trim(); brew.description = brew.description.trim() || ''; - brew.text = applyPatches(parsePatch(brewFromClient.patches), brewFromServer.text)[0]; + try { + const patches = parsePatch(brewFromClient.patches); + brew.text = applyPatches(patches, brewFromServer.text)[0]; + } catch (err) { + console.error('Failed to apply patches:', { + patches: brewFromClient.patches, + brewId: brew.editId || 'unknown' + }); + throw err; // rethrow to preserve the 500 behavior + } + brew.text = api.mergeBrewText(brew); const googleId = brew.googleId;