Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/admin-portal/src/components/Widget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ export const Widget: React.FC<WidgetProps> = ({
: globalSettings.QUERY_POLL_INTERVAL_MS,
})

useEffect(() => {
if (!taskId) {
setTaskDataStatus(status)
}
}, [status, taskId])

useEffect(() => {
if (taskData && taskData.sequent_backend_tasks_execution.length > 0) {
const task = taskData.sequent_backend_tasks_execution[0]
Expand Down
1 change: 1 addition & 0 deletions packages/admin-portal/src/resources/User/ListUsers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1161,6 +1161,7 @@ export const ListUsers: React.FC<ListUsersProps> = ({aside, electionEventId, ele
console.log(``)
console.log(`Error importing voters: ${err}`)
updateWidgetFail(currWidget.identifier)
notify(t("electionEventScreen.import.importVotersError"), {type: "error"})
}
}

Expand Down
35 changes: 26 additions & 9 deletions packages/harvest/src/routes/users.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use serde::Deserialize;
use serde::Serialize;
use std::collections::{HashMap, HashSet};
use std::env;
use tracing::{info, instrument};
use tracing::{error, info, instrument};
use uuid::Uuid;
use windmill::postgres::election_event::get_election_event_by_id;
use windmill::services::cast_votes::get_users_with_vote_info;
Expand Down Expand Up @@ -1867,20 +1867,37 @@ pub async fn import_users_f(
.may_write_secret_attributes
.then(|| ElectoralLogAdminContext::from_claims(&claims));

let _celery_task = match celery_app
if let Err(err) = celery_app
.send_task(import_users::import_users::new(
task_input,
task_execution.clone(),
))
.await
{
Ok(celery_task) => celery_task,
Err(_) => {
return Ok(Json(ImportUsersOutput {
task_execution: task_execution.clone(),
}));
}
};
error!(
"Failed to send IMPORT_USERS task {}: {err:?}",
task_execution.id
);
// The send may have failed after the task reached the queue, so only a
// task still in progress is failed and a worker's final status is kept.
// The portal's task widget reads the task by id and shows this log.
update_export_fail(
&task_execution,
&format!(
"Could not send the Import Voters task to the task queue: {err:?}. It is not known whether the task reached the queue, so check the voters before importing the file again."
),
)
.await
.map_err(|update_error| {
(
Status::InternalServerError,
format!(
"Error sending Import Voters task: {err:?}; failed to mark the task as failed: {update_error:?}"
),
)
})?;
return Ok(Json(ImportUsersOutput { task_execution }));
}

info!("Sent IMPORT_USERS task {}", task_execution.id);

Expand Down
Loading