From a9790ec579f0eca3d7c60a81794ebc362708bbb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Mon, 14 Feb 2022 15:03:17 +0100 Subject: [PATCH] API: return job from DB instead of authored job The authored job has tasks & commands in there, which shouldn't be sent as-is as an API response. Marshalling the task pointers for the inter-task dependencies would potentially produce quite large responses. --- internal/manager/api_impl/jobs.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/manager/api_impl/jobs.go b/internal/manager/api_impl/jobs.go index 75cb5cc0..03e36c84 100644 --- a/internal/manager/api_impl/jobs.go +++ b/internal/manager/api_impl/jobs.go @@ -74,7 +74,12 @@ func (f *Flamenco) SubmitJob(e echo.Context) error { return sendAPIError(e, http.StatusInternalServerError, "error persisting job in database") } - return e.JSON(http.StatusOK, authoredJob) + dbJob, err := f.persist.FetchJob(ctx, authoredJob.JobID) + if err != nil { + logger.Error().Err(err).Msg("unable to retrieve just-stored job from database") + return sendAPIError(e, http.StatusInternalServerError, "error retrieving job from database") + } + return e.JSON(http.StatusOK, dbJob) } func (f *Flamenco) FetchJob(e echo.Context, jobId string) error {