Changeset View
Standalone View
assets/src/bundles/save/index.js
Show First 20 Lines • Show All 189 Lines • ▼ Show 20 Lines | $('#swh-save-origin-form').submit(event => { | |||||||||
let originUrl = $('#swh-input-origin-url').val(); | let originUrl = $('#swh-input-origin-url').val(); | |||||||||
originSaveRequest(originType, originUrl, | originSaveRequest(originType, originUrl, | |||||||||
() => $('#swh-origin-save-request-status').html(saveRequestAcceptedAlert), | () => $('#swh-origin-save-request-status').html(saveRequestAcceptedAlert), | |||||||||
() => $('#swh-origin-save-request-status').html(saveRequestPendingAlert), | () => $('#swh-origin-save-request-status').html(saveRequestPendingAlert), | |||||||||
(statusCode, errorData) => { | (statusCode, errorData) => { | |||||||||
$('#swh-origin-save-request-status').css('color', 'red'); | $('#swh-origin-save-request-status').css('color', 'red'); | |||||||||
if (statusCode === 403) { | if (statusCode === 403) { | |||||||||
const errorAlert = htmlAlert('danger', `Error: ${errorData['detail']}`); | const errorAlert = htmlAlert('danger', `Error: ${errorData['reason']}`); | |||||||||
$('#swh-origin-save-request-status').html(errorAlert); | $('#swh-origin-save-request-status').html(errorAlert); | |||||||||
} else if (statusCode === 429) { | } else if (statusCode === 429) { | |||||||||
$('#swh-origin-save-request-status').html(saveRequestRateLimitedAlert); | $('#swh-origin-save-request-status').html(saveRequestRateLimitedAlert); | |||||||||
} else if (statusCode === 400) { | ||||||||||
ardumont: For some reason, my docker experiment showed the actual desired error message (the one
raised… | ||||||||||
Not Done Inline ActionsHmm, this detail field looks weird to me, I have the feeling that it should be reason everywhere, let me check the git history. anlambert: Hmm, this detail field looks weird to me, I have the feeling that it should be reason… | ||||||||||
Done Inline Actionsi agree. I did not check though and unshamingly relying on your memory for this ;) ardumont: i agree.
It feels like i should align everything to that.
I did not check though and… | ||||||||||
Done Inline Actions
also, we could do that to avoid modifying the utility function test below (to open the reason key)... ardumont: also, we could do that to avoid modifying the utility function test below (to open the `reason`… | ||||||||||
Done Inline Actionsalso note that i did not want to actually change that ^ (it just stayed and i missed to remove it). ardumont: also note that i did not want to actually change that ^ (it just stayed and i missed to remove… | ||||||||||
Not Done Inline ActionsTurns out I removed the python code that was returning the dict with the detail field in a really recent commit: https://forge.softwareheritage.org/rDWAPPSf9b0b666d512564fddfc2fda65b2975fa0ea75c3#change-hmkCToN48Oc7 Now that we are using the Web API endpoint to create requests, the error detail field is now reason for all error responses. anlambert: Turns out I removed the python code that was returning the dict with the detail field in a… | ||||||||||
Done Inline Actionsgreat then, i'll unify along the way (including the tests). ardumont: great then, i'll unify along the way (including the tests).
| ||||||||||
const errorAlert = htmlAlert('danger', errorData['reason']); | ||||||||||
$('#swh-origin-save-request-status').html(errorAlert); | ||||||||||
} else { | } else { | |||||||||
$('#swh-origin-save-request-status').html(saveRequestUnknownErrorAlert); | $('#swh-origin-save-request-status').html(saveRequestUnknownErrorAlert); | |||||||||
} | } | |||||||||
}); | }); | |||||||||
} else { | } else { | |||||||||
$(event.target).addClass('was-validated'); | $(event.target).addClass('was-validated'); | |||||||||
} | } | |||||||||
}); | }); | |||||||||
▲ Show 20 Lines • Show All 238 Lines • Show Last 20 Lines |
For some reason, my docker experiment showed the actual desired error message (the one
raised from the python code) was in the reason key [1] and not the detail key as the
other conditional demonstrates.
[1]