Skip to content

Commit 36d49b1

Browse files
Merge remote-tracking branch 'origin/bugfix/ARSN-494-cloudserverCrashPuttingReplicationConfiguration' into w/7.70/bugfix/ARSN-494-cloudserverCrashPuttingReplicationConfiguration
2 parents dd7ad30 + 4d12025 commit 36d49b1

File tree

3 files changed

+359
-13
lines changed

3 files changed

+359
-13
lines changed

lib/models/ReplicationConfiguration.ts

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,7 @@ export default class ReplicationConfiguration {
195195
const invalidRole = rolesArr.find((r) => !this._isValidRoleARN(r));
196196
if (invalidRole !== undefined) {
197197
return errorInstances.InvalidArgument.customizeDescription(
198-
'Invalid Role specified in replication configuration: ' +
199-
`'${invalidRole}'`
198+
`Invalid Role specified in replication configuration: '${invalidRole}'`
200199
);
201200
}
202201
this._role = role;
@@ -269,8 +268,7 @@ export default class ReplicationConfiguration {
269268
}
270269
if (prefix.length > 1024) {
271270
return errorInstances.InvalidArgument.customizeDescription(
272-
'Rule prefix ' +
273-
'cannot be longer than maximum allowed key length of 1024'
271+
'Rule prefix cannot be longer than maximum allowed key length of 1024'
274272
);
275273
}
276274
// Each Prefix in a list of rules must not overlap. For example, two
@@ -280,7 +278,7 @@ export default class ReplicationConfiguration {
280278
const used = this._configPrefixes[i];
281279
if (prefix.startsWith(used) || used.startsWith(prefix)) {
282280
return errorInstances.InvalidRequest.customizeDescription(
283-
'Found ' + `overlapping prefixes '${used}' and '${prefix}'`
281+
`Found overlapping prefixes '${used}' and '${prefix}'`
284282
);
285283
}
286284
}
@@ -296,13 +294,13 @@ export default class ReplicationConfiguration {
296294
const id = rule.ID && rule.ID[0];
297295
if (id && id.length > RULE_ID_LIMIT) {
298296
return errorInstances.InvalidArgument.customizeDescription(
299-
'Rule Id cannot be greater than 255'
297+
'Rule ID length cannot be greater than 255'
300298
);
301299
}
302300
// Each ID in a list of rules must be unique.
303301
if (id && this._configIDs.includes(id)) {
304302
return errorInstances.InvalidRequest.customizeDescription(
305-
'Rule Id must be unique'
303+
'Duplicate Rule ID'
306304
);
307305
}
308306
if (id !== undefined) {
@@ -324,14 +322,13 @@ export default class ReplicationConfiguration {
324322
replicationEndpoints[0];
325323
// StorageClass is optional.
326324
if (destination.StorageClass === undefined) {
327-
this._hasScalityDestination = defaultEndpoint.type === undefined;
325+
this._hasScalityDestination = (defaultEndpoint && defaultEndpoint.type === undefined);
328326
return undefined;
329327
}
330328
const storageClasses = destination.StorageClass[0].split(',');
331329
const isValidStorageClass = storageClasses.every((storageClass) => {
332330
if (validStorageClasses.includes(storageClass)) {
333-
this._hasScalityDestination =
334-
defaultEndpoint.type === undefined;
331+
this._hasScalityDestination = (defaultEndpoint && defaultEndpoint.type === undefined);
335332
return true;
336333
}
337334
const endpoint = replicationEndpoints.find(
@@ -344,7 +341,7 @@ export default class ReplicationConfiguration {
344341
if (!this._hasScalityDestination) {
345342
// If any endpoint does not have a type, then we know it is
346343
// a Scality destination.
347-
this._hasScalityDestination = endpoint.type === undefined;
344+
this._hasScalityDestination = (endpoint.type === undefined);
348345
}
349346
return true;
350347
}
@@ -396,7 +393,7 @@ export default class ReplicationConfiguration {
396393
// We can replicate objects only to one destination bucket.
397394
if (this._destination && this._destination !== bucketARN) {
398395
return errorInstances.InvalidRequest.customizeDescription(
399-
'The destination bucket must be same for all rules'
396+
'The destination bucket must be the same for all rules'
400397
);
401398
}
402399
this._destination = bucketARN;
@@ -427,6 +424,11 @@ export default class ReplicationConfiguration {
427424
if (err) {
428425
return err;
429426
}
427+
const { replicationEndpoints } = this._config;
428+
if (replicationEndpoints.length === 0) {
429+
return errors.InvalidRequest.customizeDescription(
430+
'No configured replication endpoint');
431+
}
430432
return this._parseRole();
431433
}
432434

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"engines": {
44
"node": ">=16"
55
},
6-
"version": "7.70.42",
6+
"version": "7.70.43",
77
"description": "Common utilities for the S3 project components",
88
"main": "build/index.js",
99
"repository": {

0 commit comments

Comments
 (0)