From 8324d275f0fd39fac51e556ef3bacd6476c264d5 Mon Sep 17 00:00:00 2001 From: Maha Benzekri Date: Fri, 22 May 2026 17:33:38 +0200 Subject: [PATCH 1/4] Simplify count-items bucket metadata handling Issue: S3UTILS-239 --- CountItems/CountWorker.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/CountItems/CountWorker.js b/CountItems/CountWorker.js index f60da543..7887ea29 100644 --- a/CountItems/CountWorker.js +++ b/CountItems/CountWorker.js @@ -5,6 +5,7 @@ const monitoring = require('../utils/monitoring'); const { deserializeBigInts, serializeBigInts } = require('./utils/utils'); const PENSIEVE = 'PENSIEVE'; + class CountWorker { constructor(params) { this.log = params.log; @@ -66,12 +67,16 @@ class CountWorker { if (!this.client.client) { return callback(new Error('NotConnected')); } - // 'fromObj' expects that the website configuration is an instance of - // WebsiteConfiguration as it is not used in CountItems, we nullify it. - if (bucketInfoObj._websiteConfiguration) { - Object.assign(bucketInfoObj, { _websiteConfiguration: null }); + const bucketInfoData = bucketInfoObj.bucketInfo || bucketInfoObj; + // 'fromObj' expects class-backed fields to already be instances. + // They are not used in CountItems, so we nullify unsupported serialized fields. + if (bucketInfoData._websiteConfiguration) { + bucketInfoData._websiteConfiguration = null; + } + if (bucketInfoData._bucketLoggingStatus) { + bucketInfoData._bucketLoggingStatus = null; } - const bucketInfo = BucketInfo.fromObj(bucketInfoObj.bucketInfo || bucketInfoObj); + const bucketInfo = BucketInfo.fromObj(bucketInfoData); const bucketName = bucketInfo.getName(); this.log.info(`${process.pid} handling ${bucketName}`); return async.waterfall([ From e9465b078566c0542217cbb8b9bd6394e06d9507 Mon Sep 17 00:00:00 2001 From: Maha Benzekri Date: Fri, 22 May 2026 17:33:38 +0200 Subject: [PATCH 2/4] Cover unsupported bucket metadata fields Issue: S3UTILS-239 --- tests/unit/CountItems/CountWorker.js | 36 ++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/tests/unit/CountItems/CountWorker.js b/tests/unit/CountItems/CountWorker.js index 846df3e0..f28a8b9b 100644 --- a/tests/unit/CountItems/CountWorker.js +++ b/tests/unit/CountItems/CountWorker.js @@ -223,6 +223,42 @@ describe('CountItems::CountWorker', () => { }); }); + test('should nullify unsupported serialized bucket info fields', done => { + const testSendFn = jest.fn(); + const w = new CountWorker({ + log: new DummyLogger(), + sendFn: testSendFn, + client: mongoMock, + }); + const bucketInfo = { + _name: 'test-bucket', + _owner: 'any', + _ownerDisplayName: 'any', + _creationDate: Date.now().toString(), + _websiteConfiguration: { + _indexDocument: 'index.html', + }, + _bucketLoggingStatus: { + _loggingEnabled: { + TargetBucket: 'target-bucket', + TargetPrefix: 'logs/', + }, + }, + }; + w.getIsTransient = jest.fn((bucketInfo, cb) => cb(null, true)); + mongoMock.setup.mockImplementationOnce(cb => cb()); + mongoMock.close.mockImplementationOnce(cb => cb()); + mongoMock.client.isConnected.mockImplementationOnce(() => false); + mongoMock.getObjectMDStats.mockImplementationOnce((_a, _b, _c, _d, cb) => cb(null, { value: 42 })); + w.countItems(bucketInfo, (err, results) => { + expect(err).toBeNull(); + expect(results).toEqual({ value: 42 }); + expect(bucketInfo._websiteConfiguration).toBeNull(); + expect(bucketInfo._bucketLoggingStatus).toBeNull(); + done(); + }); + }); + describe('CountWorker.getIsTransient method', () => { let worker; let mockBucketInfo; From 9a5c496e5136a487cd5c37c84e7b9095e5523b98 Mon Sep 17 00:00:00 2001 From: Maha Benzekri Date: Fri, 22 May 2026 17:34:47 +0200 Subject: [PATCH 3/4] bump project version Issue: S3UTILS-239 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c37a9a6d..4afc5eb0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "s3utils", - "version": "1.16.7", + "version": "1.16.8", "engines": { "node": ">= 22" }, From 2db148e255b5e9642e7ecf36f37f7fb194ffc80c Mon Sep 17 00:00:00 2001 From: Maha Benzekri Date: Wed, 10 Jun 2026 17:18:43 +0200 Subject: [PATCH 4/4] bump project versions Issue: S3UTILS-239 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 886bb11a..d1791434 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "s3utils", - "version": "1.17.11", + "version": "1.17.12", "engines": { "node": ">= 22" },