From 39bec2dd74fba94d09e8968ebab75c75039cfa18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20Papp?= Date: Mon, 17 Nov 2025 14:01:21 +0100 Subject: [PATCH] Truncate too long error response --- management/server/types/job.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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: