Skip to content

Commit

Permalink
bucket notifications - fix and improve error output for test notif (#…
Browse files Browse the repository at this point in the history
…8764)

Signed-off-by: Amit Prinz Setter <alphaprinz@gmail.com>
  • Loading branch information
alphaprinz authored Feb 5, 2025
1 parent c36719b commit d580748
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
13 changes: 12 additions & 1 deletion src/endpoint/s3/ops/s3_put_bucket_notification.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,21 @@ async function put_bucket_notification(req) {
//if test notification fails, fail the put op
const err = await notif_util.test_notifications(topic_configuration,
req.object_sdk.nsfs_config_root);

if (err) {
let message = "Test notification failed: " + (err.message || err.code);
//if there's an aggregated error, it will probably have more details in its message
if (err.name === 'AggregateError' && err.errors && err.errors[0]) {
const aggregated = err.errors[0];
message += "," + aggregated.message;
}
//for some reason in scale we are not allowed to show the config directory name in user's output
if (req.object_sdk.nsfs_config_root) {
message = message.replaceAll(req.object_sdk.nsfs_config_root, "");
}
throw new S3Error({
code: 'InvalidArgument',
message: JSON.stringify(err.message),
message,
http_code: 400,
detail: err.toString()
});
Expand Down
4 changes: 2 additions & 2 deletions src/util/notifications_util.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,9 +364,9 @@ async function test_notifications(notifs, nc_config_dir) {
connect = await notificator.parse_connect_file(notif.topic[0]);
connection = get_connection(connect);
await connection.connect();
await connection.promise_notify({notif: "test notification"}, async (notif_cb, err_cb) => {
await connection.promise_notify({notif: "test notification"}, async (notif_cb, err_cb, err) => {
failure = true;
notif_failure = err_cb;
notif_failure = err;
});
if (failure) {
if (notif_failure) {
Expand Down

0 comments on commit d580748

Please sign in to comment.