mirror of
https://github.com/netbirdio/netbird.git
synced 2026-04-20 01:06:45 +00:00
Truncate too long error response
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user