From 88bd2542570e7796f42537b74f3e750440186d55 Mon Sep 17 00:00:00 2001 From: Ned Palacios Date: Tue, 26 Mar 2024 19:54:03 +0800 Subject: [PATCH] fix(server): add null checks --- server/daemon/server/server.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/server/daemon/server/server.go b/server/daemon/server/server.go index 43b72cc..55a366b 100644 --- a/server/daemon/server/server.go +++ b/server/daemon/server/server.go @@ -405,7 +405,7 @@ func (s *Server) collect(ctx context.Context, payload types.CollectPayload) (rec report.report.Language = result.Template.Language.Name } - if result.Data.MainError != nil { + if result.Data != nil && result.Data.MainError != nil { logPayload.ErrorLine = result.Data.MainError.Nearest.StartPosition().Line logPayload.ErrorColumn = result.Data.MainError.Nearest.StartPosition().Column logPayload.FileVersion = result.Data.MainError.Document.Version @@ -450,9 +450,11 @@ func (s *Server) collect(ctx context.Context, payload types.CollectPayload) (rec s.errors = append(s.errors, report) s.notifyErrors(ctx, []resultError{report}) - // write files to the logger - for _, file := range result.Data.Documents { - s.logger.WriteVersionedFile(file.Path, []byte(file.Contents), file.Version) + if result.Data != nil && result.Data.Documents != nil { + // write files to the logger + for _, file := range result.Data.Documents { + s.logger.WriteVersionedFile(file.Path, []byte(file.Contents), file.Version) + } } return r, p, nil