Skip to content

Commit 35c6b98

Browse files
shawnzclaudesourya-deepsource
authored
Fix empty descriptions in PR and commit issue queries (#283)
* Fix empty descriptions in PR and commit issue queries The PR and commit queries read the `explanation` field from the AnalysisIssue type, which the server returns as empty. Use `issue { shortDescription }` instead, matching the pattern used by the default-branch query. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Change PR issues Issue field from pointer to value struct Prevents nil pointer dereference when accessing Issue.ShortDescription, consistent with the same pattern in run_issues.go. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Signed-off-by: Sourya Vatsyayan <sourya@deepsource.io> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Co-authored-by: Sourya Vatsyayan <sourya@deepsource.io>
1 parent 526ea0c commit 35c6b98

File tree

4 files changed

+28
-16
lines changed

4 files changed

+28
-16
lines changed

command/issues/tests/golden_files/commit_scope_response.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@
1818
"endLine": 42,
1919
"title": "Unchecked error return value of os.ReadFile",
2020
"shortcode": "GO-W1007",
21-
"explanation": "Return value of io.ReadAll is not checked for errors",
2221
"category": "BUG_RISK",
23-
"severity": "MAJOR"
22+
"severity": "MAJOR",
23+
"issue": {
24+
"shortDescription": "Return value of io.ReadAll is not checked for errors"
25+
}
2426
}
2527
},
2628
{
@@ -31,9 +33,11 @@
3133
"endLine": 91,
3234
"title": "HTTP request built with user-controlled URL",
3335
"shortcode": "GO-S1010",
34-
"explanation": "Constructing HTTP request with user-controlled URL allows SSRF",
3536
"category": "SECURITY",
36-
"severity": "MAJOR"
37+
"severity": "MAJOR",
38+
"issue": {
39+
"shortDescription": "Constructing HTTP request with user-controlled URL allows SSRF"
40+
}
3741
}
3842
}
3943
]

command/issues/tests/golden_files/pr_scope_response.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
"shortcode": "GO-W1007",
1414
"category": "BUG_RISK",
1515
"severity": "MAJOR",
16-
"explanation": "Return value of io.ReadAll is not checked for errors"
16+
"issue": {
17+
"shortDescription": "Return value of io.ReadAll is not checked for errors"
18+
}
1719
}
1820
},
1921
{
@@ -26,7 +28,9 @@
2628
"shortcode": "GO-S1010",
2729
"category": "SECURITY",
2830
"severity": "MAJOR",
29-
"explanation": "Constructing HTTP request with user-controlled URL allows SSRF"
31+
"issue": {
32+
"shortDescription": "Constructing HTTP request with user-controlled URL allows SSRF"
33+
}
3034
}
3135
}
3236
],

deepsource/issues/queries/pr_issues.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ const fetchPRIssuesQuery = `query GetPRIssues(
3636
severity
3737
explanation
3838
issue {
39+
shortDescription
3940
analyzer {
4041
name
4142
shortcode
@@ -83,7 +84,8 @@ type PRIssuesListResponse struct {
8384
Category string `json:"category"`
8485
Severity string `json:"severity"`
8586
Explanation string `json:"explanation"`
86-
Issue *struct {
87+
Issue struct {
88+
ShortDescription string `json:"shortDescription"`
8789
Analyzer struct {
8890
Name string `json:"name"`
8991
Shortcode string `json:"shortcode"`
@@ -142,7 +144,7 @@ func (r *PRIssuesListRequest) Do(ctx context.Context) ([]issues.Issue, error) {
142144
IssueCategory: node.Category,
143145
IssueSeverity: node.Severity,
144146
IssueSource: node.Source,
145-
Description: node.Explanation,
147+
Description: node.Issue.ShortDescription,
146148
Location: issues.Location{
147149
Path: node.Path,
148150
Position: issues.Position{
@@ -151,11 +153,9 @@ func (r *PRIssuesListRequest) Do(ctx context.Context) ([]issues.Issue, error) {
151153
},
152154
},
153155
}
154-
if node.Issue != nil {
155-
issue.Analyzer = issues.AnalyzerMeta{
156-
Name: node.Issue.Analyzer.Name,
157-
Shortcode: node.Issue.Analyzer.Shortcode,
158-
}
156+
issue.Analyzer = issues.AnalyzerMeta{
157+
Name: node.Issue.Analyzer.Name,
158+
Shortcode: node.Issue.Analyzer.Shortcode,
159159
}
160160
allIssues = append(allIssues, issue)
161161
}

deepsource/issues/queries/run_issues.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@ const fetchRunIssuesFlatQuery = `query GetRunIssues($commitOid: String!, $limit:
2727
endLine
2828
title
2929
shortcode
30-
explanation
3130
category
3231
severity
32+
issue {
33+
shortDescription
34+
}
3335
}
3436
}
3537
}
@@ -70,9 +72,11 @@ type RunIssuesFlatResponse struct {
7072
EndLine int `json:"endLine"`
7173
Title string `json:"title"`
7274
Shortcode string `json:"shortcode"`
73-
Explanation string `json:"explanation"`
7475
Category string `json:"category"`
7576
Severity string `json:"severity"`
77+
Issue struct {
78+
ShortDescription string `json:"shortDescription"`
79+
} `json:"issue"`
7680
} `json:"node"`
7781
} `json:"edges"`
7882
} `json:"issues"`
@@ -119,7 +123,7 @@ func (r *RunIssuesFlatRequest) Do(ctx context.Context) ([]issues.Issue, error) {
119123
IssueCategory: node.Category,
120124
IssueSeverity: node.Severity,
121125
IssueSource: node.Source,
122-
Description: node.Explanation,
126+
Description: node.Issue.ShortDescription,
123127
Location: issues.Location{
124128
Path: node.Path,
125129
Position: issues.Position{

0 commit comments

Comments
 (0)