mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-08-21 00:02:23 +00:00
improve app handling of job with error keys
This commit is contained in:
@@ -5035,6 +5035,8 @@ paths:
|
||||
completed:
|
||||
type: boolean
|
||||
result: {}
|
||||
success:
|
||||
type: boolean
|
||||
started:
|
||||
type: boolean
|
||||
required:
|
||||
|
||||
@@ -794,7 +794,7 @@ async fn multipart_upload_s3_file(
|
||||
.unwrap_or_default()
|
||||
.as_millis(),
|
||||
rand::random::<u16>(),
|
||||
query.file_extension.unwrap_or("file".to_string())
|
||||
query.file_extension.clone().unwrap_or("file".to_string())
|
||||
)
|
||||
.to_string()
|
||||
}
|
||||
|
||||
@@ -3130,6 +3130,12 @@ pub struct RawResult<'a> {
|
||||
pub result: &'a JsonRawValue,
|
||||
}
|
||||
|
||||
#[derive(FromRow)]
|
||||
pub struct RawResultWithSuccess<'a> {
|
||||
pub result: &'a JsonRawValue,
|
||||
pub success: bool,
|
||||
}
|
||||
|
||||
impl<'a> IntoResponse for RawResult<'a> {
|
||||
fn into_response(self) -> Response {
|
||||
Json(self.result).into_response()
|
||||
@@ -3170,6 +3176,7 @@ async fn get_completed_job_result(
|
||||
#[derive(Serialize)]
|
||||
struct CompletedJobResult<'c> {
|
||||
started: Option<bool>,
|
||||
success: Option<bool>,
|
||||
completed: bool,
|
||||
result: Option<&'c JsonRawValue>,
|
||||
}
|
||||
@@ -3184,17 +3191,19 @@ async fn get_completed_job_result_maybe(
|
||||
Path((w_id, id)): Path<(String, Uuid)>,
|
||||
Query(GetCompletedJobQuery { get_started }): Query<GetCompletedJobQuery>,
|
||||
) -> error::Result<Response> {
|
||||
let result_o =
|
||||
sqlx::query("SELECT result FROM completed_job WHERE id = $1 AND workspace_id = $2")
|
||||
.bind(id)
|
||||
.bind(&w_id)
|
||||
.fetch_optional(&db)
|
||||
.await?;
|
||||
let result_o = sqlx::query(
|
||||
"SELECT result, success FROM completed_job WHERE id = $1 AND workspace_id = $2",
|
||||
)
|
||||
.bind(id)
|
||||
.bind(&w_id)
|
||||
.fetch_optional(&db)
|
||||
.await?;
|
||||
|
||||
if let Some(result) = result_o {
|
||||
let res = RawResult::from_row(&result)?;
|
||||
let res = RawResultWithSuccess::from_row(&result)?;
|
||||
Ok(Json(CompletedJobResult {
|
||||
started: Some(true),
|
||||
success: Some(res.success),
|
||||
completed: true,
|
||||
result: Some(res.result),
|
||||
})
|
||||
@@ -3208,15 +3217,21 @@ async fn get_completed_job_result_maybe(
|
||||
.fetch_optional(&db)
|
||||
.await?
|
||||
.unwrap_or(false);
|
||||
Ok(
|
||||
Json(CompletedJobResult { started: Some(started), completed: false, result: None })
|
||||
.into_response(),
|
||||
)
|
||||
Ok(Json(CompletedJobResult {
|
||||
started: Some(started),
|
||||
completed: false,
|
||||
success: None,
|
||||
result: None,
|
||||
})
|
||||
.into_response())
|
||||
} else {
|
||||
Ok(
|
||||
Json(CompletedJobResult { started: None, completed: false, result: None })
|
||||
.into_response(),
|
||||
)
|
||||
Ok(Json(CompletedJobResult {
|
||||
started: None,
|
||||
completed: false,
|
||||
success: None,
|
||||
result: None,
|
||||
})
|
||||
.into_response())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
import type { SupportedLanguage } from '$lib/common'
|
||||
|
||||
export let isLoading = false
|
||||
export let job: { completed: boolean; result: any; id: string } | undefined = undefined
|
||||
export let job: { completed: boolean; result: any; id: string; success?: boolean } | undefined =
|
||||
undefined
|
||||
export let workspaceOverride: string | undefined = undefined
|
||||
export let notfound = false
|
||||
export let isEditor = false
|
||||
@@ -177,7 +178,7 @@
|
||||
if (currentId === id || allowConcurentRequests) {
|
||||
job = { ...maybe_job, id }
|
||||
await tick()
|
||||
if (typeof job?.result == 'object' && 'error' in (job?.result ?? {})) {
|
||||
if (!job?.success && typeof job?.result == 'object' && 'error' in (job?.result ?? {})) {
|
||||
callbacks?.error()
|
||||
dispatch('doneError', {
|
||||
id,
|
||||
|
||||
Reference in New Issue
Block a user