Skip to content

Commit d580748

Browse files
authored
bucket notifications - fix and improve error output for test notif (#8764)
Signed-off-by: Amit Prinz Setter <alphaprinz@gmail.com>
1 parent c36719b commit d580748

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/endpoint/s3/ops/s3_put_bucket_notification.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,21 @@ async function put_bucket_notification(req) {
2929
//if test notification fails, fail the put op
3030
const err = await notif_util.test_notifications(topic_configuration,
3131
req.object_sdk.nsfs_config_root);
32+
3233
if (err) {
34+
let message = "Test notification failed: " + (err.message || err.code);
35+
//if there's an aggregated error, it will probably have more details in its message
36+
if (err.name === 'AggregateError' && err.errors && err.errors[0]) {
37+
const aggregated = err.errors[0];
38+
message += "," + aggregated.message;
39+
}
40+
//for some reason in scale we are not allowed to show the config directory name in user's output
41+
if (req.object_sdk.nsfs_config_root) {
42+
message = message.replaceAll(req.object_sdk.nsfs_config_root, "");
43+
}
3344
throw new S3Error({
3445
code: 'InvalidArgument',
35-
message: JSON.stringify(err.message),
46+
message,
3647
http_code: 400,
3748
detail: err.toString()
3849
});

src/util/notifications_util.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,9 +364,9 @@ async function test_notifications(notifs, nc_config_dir) {
364364
connect = await notificator.parse_connect_file(notif.topic[0]);
365365
connection = get_connection(connect);
366366
await connection.connect();
367-
await connection.promise_notify({notif: "test notification"}, async (notif_cb, err_cb) => {
367+
await connection.promise_notify({notif: "test notification"}, async (notif_cb, err_cb, err) => {
368368
failure = true;
369-
notif_failure = err_cb;
369+
notif_failure = err;
370370
});
371371
if (failure) {
372372
if (notif_failure) {

0 commit comments

Comments
 (0)