Skip to content

Commit ae47a17

Browse files
authored
remove details from annotation 🖍️ (#7)
Remove the `details` field from all annotations. In certain conditions, including this field (which was filled with a marshalled JSON string) appears to be causing a validation error in posting an initial check creation to GitHub. In the reproduced error cases, the post body remained valid JSON, but nonetheless removing the `details` field resolved the validation issue.
1 parent b274426 commit ae47a17

File tree

4 files changed

+12
-15
lines changed

4 files changed

+12
-15
lines changed

converter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,5 @@ func resultToAnnotation(result sarif.Result) (*github.Annotation, error) {
5555

5656
title := result.RuleID
5757

58-
return github.CreateAnnotation(result.Locations[0].Filepath, startLine, endLine, result.Level, title, result.Message, result.Raw)
58+
return github.CreateAnnotation(result.Locations[0].Filepath, startLine, endLine, result.Level, title, result.Message)
5959
}

converter_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func TestSarifToAnnotationConverter(t *testing.T) {
2020
sarif.ResultLocation{Filepath: "test/file", StartLine: &five}},
2121
}
2222
// accuracy of annotation creation tested elsewhere
23-
annotationWithStartLine, _ := github.CreateAnnotation("test/file", five, five, "error", "fail-1-2-3", "this is a failure", "raw failure text")
23+
annotationWithStartLine, _ := github.CreateAnnotation("test/file", five, five, "error", "fail-1-2-3", "this is a failure")
2424

2525
sarifWithStartAndEndLine := sarif.Result{
2626
Message: "this is a failure",
@@ -31,7 +31,7 @@ func TestSarifToAnnotationConverter(t *testing.T) {
3131
sarif.ResultLocation{Filepath: "test/file", StartLine: &five, EndLine: &ten}},
3232
}
3333
// accuracy of annotation creation tested elsewhere
34-
annotationWithStartAndEndLine, _ := github.CreateAnnotation("test/file", five, ten, "error", "fail-1-2-3", "this is a failure", "raw failure text")
34+
annotationWithStartAndEndLine, _ := github.CreateAnnotation("test/file", five, ten, "error", "fail-1-2-3", "this is a failure")
3535

3636
tests := []struct {
3737
name string
@@ -100,8 +100,8 @@ func TestSarifsToAnnotationsConverter(t *testing.T) {
100100
sarif.ResultLocation{Filepath: "test/file", StartLine: &five}},
101101
}
102102
// accuracy of annotation creation tested elsewhere
103-
annotationOriginal, _ := github.CreateAnnotation("test/file", five, five, "error", "fail-1-2-3", "this is a failure", "raw failure text")
104-
annotationOriginalReportedTwice, _ := github.CreateAnnotation("test/file", five, five, "error", "fail-1-2-3 (reported 2 times)", "this is a failure", "raw failure text")
103+
annotationOriginal, _ := github.CreateAnnotation("test/file", five, five, "error", "fail-1-2-3", "this is a failure")
104+
annotationOriginalReportedTwice, _ := github.CreateAnnotation("test/file", five, five, "error", "fail-1-2-3 (reported 2 times)", "this is a failure")
105105

106106
sarifAsWarning := sarif.Result{
107107
Message: "this is a failure",
@@ -112,8 +112,8 @@ func TestSarifsToAnnotationsConverter(t *testing.T) {
112112
sarif.ResultLocation{Filepath: "test/file", StartLine: &five}},
113113
}
114114
// accuracy of annotation creation tested elsewhere
115-
annotationAsWarning, _ := github.CreateAnnotation("test/file", five, five, "warning", "fail-1-2-3", "this is a failure", "raw failure text")
116-
annotationAsWarningReportedTwice, _ := github.CreateAnnotation("test/file", five, five, "warning", "fail-1-2-3 (reported 2 times)", "this is a failure", "raw failure text")
115+
annotationAsWarning, _ := github.CreateAnnotation("test/file", five, five, "warning", "fail-1-2-3", "this is a failure")
116+
annotationAsWarningReportedTwice, _ := github.CreateAnnotation("test/file", five, five, "warning", "fail-1-2-3 (reported 2 times)", "this is a failure")
117117

118118
sarifNewId := sarif.Result{
119119
Message: "this is a failure",
@@ -124,7 +124,7 @@ func TestSarifsToAnnotationsConverter(t *testing.T) {
124124
sarif.ResultLocation{Filepath: "test/file", StartLine: &five}},
125125
}
126126
// accuracy of annotation creation tested elsewhere
127-
annotationNewId, _ := github.CreateAnnotation("test/file", five, five, "error", "new-id-3", "this is a failure", "raw failure text")
127+
annotationNewId, _ := github.CreateAnnotation("test/file", five, five, "error", "new-id-3", "this is a failure")
128128

129129
sarifNewStartLine := sarif.Result{
130130
Message: "this is a failure",
@@ -135,7 +135,7 @@ func TestSarifsToAnnotationsConverter(t *testing.T) {
135135
sarif.ResultLocation{Filepath: "test/file", StartLine: &six}},
136136
}
137137
// accuracy of annotation creation tested elsewhere
138-
annotationNewStartLine, _ := github.CreateAnnotation("test/file", six, six, "error", "new-id-3", "this is a failure", "raw failure text")
138+
annotationNewStartLine, _ := github.CreateAnnotation("test/file", six, six, "error", "new-id-3", "this is a failure")
139139

140140
sarifNewEndLine := sarif.Result{
141141
Message: "this is a failure",
@@ -146,7 +146,7 @@ func TestSarifsToAnnotationsConverter(t *testing.T) {
146146
sarif.ResultLocation{Filepath: "test/file", StartLine: &five, EndLine: &ten}},
147147
}
148148
// accuracy of annotation creation tested elsewhere
149-
annotationNewEndLine, _ := github.CreateAnnotation("test/file", five, ten, "error", "new-id-3", "this is a failure", "raw failure text")
149+
annotationNewEndLine, _ := github.CreateAnnotation("test/file", five, ten, "error", "new-id-3", "this is a failure")
150150

151151
tests := []struct {
152152
name string

github/annotation.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func levelStringToNormalizedLevel(level string) (normalizedLevel int, normalized
7272
return
7373
}
7474

75-
func CreateAnnotation(path string, startLine int, endLine int, level string, title string, message string, details string) (*Annotation, error) {
75+
func CreateAnnotation(path string, startLine int, endLine int, level string, title string, message string) (*Annotation, error) {
7676
normalizedLevel, normalizedLevelString, err := levelStringToNormalizedLevel(level)
7777
if err != nil {
7878
return nil, errors.Wrap(err, "failed to normalize level")
@@ -86,7 +86,6 @@ func CreateAnnotation(path string, startLine int, endLine int, level string, tit
8686
Title: &title,
8787
Message: &message,
8888
AnnotationLevel: &normalizedLevelString,
89-
RawDetails: &details,
9089
},
9190
level: normalizedLevel,
9291
fileName: path,

github/annotation_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,8 @@ func TestCreateAnnotation(t *testing.T) {
138138
level := "warning"
139139
title := "Finding title"
140140
message := "Finding message"
141-
details := "raw finding details"
142141

143-
got, err := CreateAnnotation(path, startLine, endLine, level, title, message, details)
142+
got, err := CreateAnnotation(path, startLine, endLine, level, title, message)
144143
if err != nil {
145144
t.Error(errors.Wrap(err, "failed to create annotation"))
146145
}
@@ -153,7 +152,6 @@ func TestCreateAnnotation(t *testing.T) {
153152
Title: &title,
154153
Message: &message,
155154
AnnotationLevel: &level,
156-
RawDetails: &details,
157155
},
158156
level: warningLevel,
159157
fileName: path,

0 commit comments

Comments
 (0)