Skip to content

Jira V2 contact point: search request sends 'expand' as empty string instead of omitting it #482

@guhcostan

Description

@guhcostan

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

  1. Configure a Jira contact point in Grafana Alerting with a Jira Server v2 URL (e.g., https://your-jira.com/rest/api/2)
  2. Fill in Project Key, Issue Type, and authentication
  3. Click "Test" to send a test notification
  4. The test fails with the deserialization error above

Metadata

Metadata

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

Status

Needs triage

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions