fix: job completion stuck in running - NULL output and status type mismatch
Some checks failed
CI Pipeline / Rust Format Check (push) Failing after 4s
CI Pipeline / Clippy Lints (push) Successful in 45s
CI Pipeline / Rust Unit Tests (push) Successful in 1m2s
CI Pipeline / Security Audit (push) Successful in 4s
CI Pipeline / Frontend Lint & Type Check (push) Failing after 10s
CI Pipeline / Build .deb & Release (push) Has been skipped
Some checks failed
CI Pipeline / Rust Format Check (push) Failing after 4s
CI Pipeline / Clippy Lints (push) Successful in 45s
CI Pipeline / Rust Unit Tests (push) Successful in 1m2s
CI Pipeline / Security Audit (push) Successful in 4s
CI Pipeline / Frontend Lint & Type Check (push) Failing after 10s
CI Pipeline / Build .deb & Release (push) Has been skipped
Bug 1: status.output.as_deref() passes NULL when agent returns no output,
but patch_job_hosts.output has NOT NULL constraint.
Fix: use .unwrap_or("") to default to empty string.
Bug 2: sync_job_status passes String to job_status enum column,
PostgreSQL rejects implicit text-to-enum cast.
Fix: add ::job_status cast in SQL UPDATE queries.
This commit is contained in:
@ -690,7 +690,7 @@ async fn poll_single_host(pool: PgPool, config: Arc<AppConfig>, row: PatchJobHos
|
||||
"#,
|
||||
)
|
||||
.bind(row.id)
|
||||
.bind(status.output.as_deref())
|
||||
.bind(status.output.as_deref().unwrap_or(""))
|
||||
.execute(&pool)
|
||||
.await
|
||||
{
|
||||
@ -906,7 +906,7 @@ async fn sync_job_status(pool: &PgPool, job_id: Uuid) {
|
||||
sqlx::query(
|
||||
r#"
|
||||
UPDATE patch_jobs
|
||||
SET status = $2,
|
||||
SET status = $2::job_status,
|
||||
completed_at = COALESCE(completed_at, NOW())
|
||||
WHERE id = $1
|
||||
"#,
|
||||
@ -916,7 +916,7 @@ async fn sync_job_status(pool: &PgPool, job_id: Uuid) {
|
||||
.execute(pool)
|
||||
.await
|
||||
} else {
|
||||
sqlx::query("UPDATE patch_jobs SET status = $2 WHERE id = $1")
|
||||
sqlx::query("UPDATE patch_jobs SET status = $2::job_status WHERE id = $1")
|
||||
.bind(job_id)
|
||||
.bind(new_status)
|
||||
.execute(pool)
|
||||
|
||||
Reference in New Issue
Block a user