Skip to content

Commit 1a18d2a

Browse files
committed
YDA-6574: fix wrong error handling in group manager resulting in generic internal error
1 parent bb8d8f6 commit 1a18d2a

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

group_manager/group_manager.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def group_create() -> Response:
104104
'description': request.form['group_description'],
105105
'data_classification': data_classification})
106106

107-
output = make_response({'status': 0 if response['status'] == 'ok' else 1, 'message': response['status_info']})
107+
output = make_response(response)
108108
output.headers["Content-type"] = "application/json"
109109
return output
110110

@@ -129,6 +129,6 @@ def group_update() -> Response:
129129
if not property_updated:
130130
response = {'status': 'ok', 'status_info': 'Nothing changed'}
131131

132-
output = make_response({'status': 0 if response['status'] == 'ok' else 1, 'message': response['status_info']})
132+
output = make_response(response)
133133
output.headers["Content-type"] = "application/json"
134134
return output

group_manager/static/group_manager/js/group_manager.js

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -394,9 +394,7 @@ async function processImportedRow (row) {
394394
{ quiet: true, rawResult: true })
395395
// Check if response is not null and handle it
396396
if (response) {
397-
const status = response.status
398-
399-
if (status === 'ok') {
397+
if (response.status === 'ok') {
400398
// Successful import -> set correct classes and feedback to inform user
401399
row.addClass('import-groupname-done')
402400
$('#processed-indicator-' + groupname).html('<i class="fa-solid fa-check"></i>')
@@ -550,7 +548,7 @@ async function processUserroleChange (row, newRole, groupName) {
550548
row.removeClass('active')
551549

552550
// Handle error
553-
const errorMessage = result.message || result.status_info ||
551+
const errorMessage = result.status_info ||
554552
'Error: Could not change the role for the selected member due to an internal error.\n' +
555553
'Please contact a Yoda administrator'
556554
Yoda.set_message('error', errorMessage)
@@ -591,7 +589,7 @@ async function removeUserFromGroup (row, groupName) {
591589
}
592590
} else {
593591
// Handle error
594-
const errorMessage = result.message ||
592+
const errorMessage = result.status_info ||
595593
'Error: Could not remove the selected member from the group due to an internal error.\n' +
596594
'Please contact a Yoda administrator'
597595
window.alert(errorMessage)
@@ -1937,7 +1935,7 @@ $(function () {
19371935
dataType: 'json',
19381936
data: postData
19391937
}).done(function (result) {
1940-
if ('status' in result && result.status === 0) {
1938+
if ('status' in result && result.status === 'ok') {
19411939
// OK! Make sure the newly added group is selected after reloading the page.
19421940
Yoda.storage.session.set('selected-group', postData.group_name)
19431941

@@ -1959,8 +1957,8 @@ $(function () {
19591957
// Something went wrong.
19601958
resetSubmitButton()
19611959

1962-
if ('message' in result) {
1963-
window.alert(result.message)
1960+
if ('status_info' in result) {
1961+
window.alert(result.status_info)
19641962
} else {
19651963
window.alert(
19661964
'Error: Could not ' + action + ' group due to an internal error.\n' +
@@ -2015,9 +2013,7 @@ $(function () {
20152013
// Re-enable group list entry.
20162014
$('#group-list .group.delete-pending[data-name="' + Yoda.escapeQuotes(groupName) + '"]').removeClass('delete-pending disabled').attr('title', '')
20172015

2018-
if ('message' in result) {
2019-
window.alert(result.message)
2020-
} else if ('status_info' in result) {
2016+
if ('status_info' in result) {
20212017
window.alert(result.status_info)
20222018
} else {
20232019
window.alert(
@@ -2098,7 +2094,9 @@ $(function () {
20982094
$('.selectify-user-name').trigger('select2:open')
20992095
} else {
21002096
// Something went wrong. :(
2101-
if ('message' in result) { window.alert(result.message) } else {
2097+
if ('status_info' in result) {
2098+
window.alert(result.status_info)
2099+
} else {
21022100
window.alert(
21032101
'Error: Could not add a member due to an internal error.\n' +
21042102
'Please contact a Yoda administrator'

0 commit comments

Comments
 (0)