Description
When using the Jira contact point with Jira Server/Data Center (REST API v2), the search for existing issues fails with a 400 error because the expand field in the issueSearch struct is serialized as an empty string ("expand": "") instead of being omitted.
Jira Server v2 /search endpoint expects expand to be an array ([]string), not a string. Sending an empty string causes the following error:
failed to look up existing issues: HTTP request to JIRA API: webhook failed validation: unexpected status code 400:
{"errorMessages":["Can not deserialize instance of java.util.ArrayList out of VALUE_STRING token
at [Source: ...; line: 1, column: 2]
(through reference chain: com.atlassian.jira.rest.v2.search.SearchRequestBean[\"expand\"])"]}
Root Cause
In receivers/jira/v1/types.go, the issueSearch struct defines Expand as:
type issueSearch struct {
Expand string `json:"expand"`
Fields []string `json:"fields"`
JQL string `json:"jql"`
MaxResults int `json:"maxResults"`
}
Since Expand is a string without omitempty, and getSearchJql() in jira.go never sets the Expand field, it serializes to "expand": "" in the JSON body. Jira Server's v2 API rejects this because it expects an array.
Suggested Fix
Add omitempty to the JSON tag:
Expand string `json:"expand,omitempty"`
Or change the type to []string to match Jira's expected format:
Expand []string `json:"expand,omitempty"`
Related
Environment
- Grafana: Cloud Advanced v12.4.0
- Jira: Server/Data Center (self-hosted, REST API v2)
Steps to Reproduce
- Configure a Jira contact point in Grafana Alerting with a Jira Server v2 URL (e.g.,
https://your-jira.com/rest/api/2)
- Fill in Project Key, Issue Type, and authentication
- Click "Test" to send a test notification
- The test fails with the deserialization error above
Description
When using the Jira contact point with Jira Server/Data Center (REST API v2), the search for existing issues fails with a 400 error because the
expandfield in theissueSearchstruct is serialized as an empty string ("expand": "") instead of being omitted.Jira Server v2
/searchendpoint expectsexpandto be an array ([]string), not a string. Sending an empty string causes the following error:Root Cause
In
receivers/jira/v1/types.go, theissueSearchstruct definesExpandas:Since
Expandis astringwithoutomitempty, andgetSearchJql()injira.gonever sets theExpandfield, it serializes to"expand": ""in the JSON body. Jira Server's v2 API rejects this because it expects an array.Suggested Fix
Add
omitemptyto the JSON tag:Or change the type to
[]stringto match Jira's expected format:Related
/searchinstead of/search/jql) but did not address theexpandfield serialization.Environment
Steps to Reproduce
https://your-jira.com/rest/api/2)