mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-08-23 08:00:45 +00:00
fix: surface postgres error detail when datatable migrations fail to run
This commit is contained in:
@@ -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(())
|
||||
}
|
||||
|
||||
@@ -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 = {
|
||||
|
||||
Reference in New Issue
Block a user