diff --git a/management/server/types/job.go b/management/server/types/job.go index d51d2fa38..fd778ba5f 100644 --- a/management/server/types/job.go +++ b/management/server/types/job.go @@ -26,6 +26,11 @@ const ( JobTypeBundle JobType = "bundle" ) +const ( + // MaxJobReasonLength is the maximum length allowed for job failure reasons + MaxJobReasonLength = 4096 +) + type Job struct { // ID is the primary identifier ID string `gorm:"primaryKey"` @@ -171,7 +176,11 @@ func (j *Job) ApplyResponse(resp *proto.JobResponse) error { case proto.JobStatus_failed: j.Status = JobStatusFailed if len(resp.Reason) > 0 { - j.FailedReason = fmt.Sprintf("Client error: '%s'", resp.Reason) + reason := string(resp.Reason) + if len(resp.Reason) > MaxJobReasonLength { + reason = string(resp.Reason[:MaxJobReasonLength]) + "... (truncated)" + } + j.FailedReason = fmt.Sprintf("Client error: '%s'", reason) } return nil default: