From 42c62a3388026ad76f17456e9c8c25db1ea0b170 Mon Sep 17 00:00:00 2001 From: Dimitrios Vasilas Date: Fri, 16 Jan 2026 18:35:29 +0200 Subject: [PATCH 1/2] CLDSRV-830: Fix NaN serialization as null in access logs Server access logs contain explicit null values for bytesReceived and contentLength when parsedContentLength is NaN. This happens when Number.parseInt('', 10) returns NaN, which JSON.stringify then serializes as null instead of omitting the field. Add Number.isNaN() checks to convert NaN to undefined, allowing JSON.stringify to omit these fields as intended. --- lib/utilities/serverAccessLogger.js | 4 ++-- tests/unit/utils/serverAccessLogger.js | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/lib/utilities/serverAccessLogger.js b/lib/utilities/serverAccessLogger.js index b474cc81ef..a08bb4e337 100644 --- a/lib/utilities/serverAccessLogger.js +++ b/lib/utilities/serverAccessLogger.js @@ -416,11 +416,11 @@ function logServerAccess(req, res) { userName: params.analyticsUserName ?? undefined, httpMethod: req.method ?? undefined, bytesDeleted: params.analyticsBytesDeleted ?? undefined, - bytesReceived: req.parsedContentLength ?? undefined, + bytesReceived: Number.isInteger(req.parsedContentLength) ? req.parsedContentLength : undefined, bodyLength: req.headers['content-length'] !== undefined ? parseInt(req.headers['content-length'], 10) : undefined, - contentLength: req.parsedContentLength ?? undefined, + contentLength: Number.isInteger(req.parsedContentLength) ? req.parsedContentLength : undefined, // eslint-disable-next-line camelcase elapsed_ms: calculateElapsedMS(params.startTime, params.onCloseEndTime) ?? undefined, diff --git a/tests/unit/utils/serverAccessLogger.js b/tests/unit/utils/serverAccessLogger.js index 49aa1abae7..3dece84834 100644 --- a/tests/unit/utils/serverAccessLogger.js +++ b/tests/unit/utils/serverAccessLogger.js @@ -1122,6 +1122,29 @@ describe('serverAccessLogger utility functions', () => { assert.strictEqual(loggedData.errorCode, 'NoSuchKey'); assert.strictEqual('errorCode' in loggedData, true); }); + + it('should omit NaN fields from log output', () => { + setServerAccessLogger(mockLogger); + const req = { + serverAccessLog: {}, + headers: {}, + parsedContentLength: NaN, // Simulates Number.parseInt('', 10) + socket: {}, + }; + const res = { + serverAccessLog: {}, + getHeader: () => null, + }; + + logServerAccess(req, res); + + assert.strictEqual(mockLogger.write.callCount, 1); + const loggedData = JSON.parse(mockLogger.write.firstCall.args[0].trim()); + + // NaN values should be omitted from the log output + assert.strictEqual('bytesReceived' in loggedData, false); + assert.strictEqual('contentLength' in loggedData, false); + }); }); }); From 23e383a91082a9a88e0689bb008cc0eb93fa0114 Mon Sep 17 00:00:00 2001 From: Dimitrios Vasilas Date: Fri, 16 Jan 2026 18:37:11 +0200 Subject: [PATCH 2/2] CLDSRV-830: Bump version to 9.2.15 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 722bed4eec..e6fe2b0bdb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@zenko/cloudserver", - "version": "9.2.14", + "version": "9.2.15", "description": "Zenko CloudServer, an open-source Node.js implementation of a server handling the Amazon S3 protocol", "main": "index.js", "engines": {