fix: surface postgres error detail when datatable migrations fail to run

This commit is contained in:
Diego Imbert
2026-06-18 23:34:55 +02:00
parent d234001e63
commit e98dcd3579
2 changed files with 16 additions and 6 deletions
@@ -2546,10 +2546,18 @@ async fn run_datatable_migration_job(
let (result, success) =
run_wait_result_internal(db, uuid, w_id, None, false, &authed.username).await?;
if !success {
return Err(Error::internal_err(format!(
"migration job failed: {}",
result.get()
)));
// On failure the job result is `{"error": {"name", "message", ...}}`;
// surface the executor's message (the Postgres error, e.g. `relation
// "foo" does not exist`) instead of the raw JSON envelope.
let detail = serde_json::from_str::<serde_json::Value>(result.get())
.ok()
.as_ref()
.and_then(|v| v.get("error"))
.and_then(|e| e.get("message"))
.and_then(|m| m.as_str())
.map(str::to_string)
.unwrap_or_else(|| result.get().to_string());
return Err(Error::internal_err(detail));
}
Ok(())
}
+4 -2
View File
@@ -4999,8 +4999,10 @@ export async function push(
yes: opts.yes,
jsonOutput: opts.jsonOutput,
});
} catch (e) {
log.warn(`Failed to run new datatable migrations: ${e}`);
} catch (e: any) {
log.warn(
`Failed to run new datatable migrations: ${e?.body ?? e?.message ?? e}`,
);
}
if (opts.jsonOutput) {
const result = {