diff --git a/libraries/logger/CHANGELOG.md b/libraries/logger/CHANGELOG.md index c130189ccc..a581cf4077 100644 --- a/libraries/logger/CHANGELOG.md +++ b/libraries/logger/CHANGELOG.md @@ -1,3 +1,7 @@ +## v3.1.1 + +* Handle malformed requests in the req serializer + ## v3.0.0 * Improve logging in Google Cloud Platform. Set environment variable `GCP_LOGGING=true` to enable. diff --git a/libraries/logger/package.json b/libraries/logger/package.json index 7d6d0337db..78e9a74595 100644 --- a/libraries/logger/package.json +++ b/libraries/logger/package.json @@ -7,7 +7,7 @@ "url": "https://github.com/overleaf/overleaf" }, "license": "AGPL-3.0-only", - "version": "3.1.0", + "version": "3.1.1", "scripts": { "test": "mocha --grep=$MOCHA_GREP test/**/*.js", "format": "prettier --list-different $PWD/'**/*.js'", diff --git a/libraries/logger/serializers.js b/libraries/logger/serializers.js index 28581d863f..37b84e60e3 100644 --- a/libraries/logger/serializers.js +++ b/libraries/logger/serializers.js @@ -29,18 +29,20 @@ function reqSerializer(req) { 'content-length': headers['content-length'], }, } - const projectId = - req.params.projectId || req.params.project_id || req.params.Project_id - const userId = req.params.userId || req.params.user_id - const docId = req.params.docId || req.params.doc_id - if (projectId) { - entry.projectId = projectId - } - if (userId) { - entry.userId = userId - } - if (docId) { - entry.docId = docId + if (req.params) { + const projectId = + req.params.projectId || req.params.project_id || req.params.Project_id + const userId = req.params.userId || req.params.user_id + const docId = req.params.docId || req.params.doc_id + if (projectId) { + entry.projectId = projectId + } + if (userId) { + entry.userId = userId + } + if (docId) { + entry.docId = docId + } } return entry }