wtfutil/wtf · error

JIRA search failed: %v

Error message

JIRA search failed: %v

What it means

IssuesFor fails with this error when searchWithNewAPI - the Jira Cloud v3 /rest/api/3/search/jql endpoint - returns an error. The error propagates the underlying cause, meaning the search request itself failed (transport, auth, or API rejection); it is not a parse failure of a successful response.

Source

Thrown at modules/jira/client.go:204

	if username != "" {
		// Convert JQL with username to account ID
		convertedJQL, err := widget.ConvertJQLWithUsername(username)
		if err != nil {
			return &SearchResult{}, fmt.Errorf("failed to convert username %s to account ID: %v", username, err)
		}
		query = append(query, convertedJQL)
	}

	if jql != "" {
		query = append(query, jql)
	}

	// Try the new API v3 search/jql endpoint
	jqlQuery := strings.Join(query, " AND ")
	searchResult, err := widget.searchWithNewAPI(jqlQuery)
	if err != nil {
		// If new API fails, return the error
		return &SearchResult{}, fmt.Errorf("JIRA search failed: %v", err)
	}

	return searchResult, nil
}

// searchWithNewAPI uses the new /rest/api/3/search/jql endpoint
func (widget *Widget) searchWithNewAPI(jql string) (*SearchResult, error) {
	// First, get issue IDs using the new endpoint
	v := url.Values{}
	v.Set("jql", jql)
	v.Set("maxResults", "20") // Limit to avoid too many API calls

	jqlURL := fmt.Sprintf("/rest/api/3/search/jql?%s", v.Encode())

	resp, err := widget.jiraRequest(jqlURL)
	if err != nil {
		return nil, err
	}

View on GitHub (pinned to bb838c1ccb)

Solutions

  1. Read the wrapped error (%v) for the HTTP status or transport cause
  2. Validate the API token and site URL in the Jira widget config
  3. Test the joined JQL manually in Jira's search to find syntax problems
  4. Check Atlassian's API changelog for search/jql endpoint changes and update the client

Example fix

// before
query := "assignee = " + username
// after (valid converted clause)
query := "accountID in (\"5f2a3b4c5d6e7f8a9b0c1d2e\")"
Defensive patterns

Strategy: try-catch

Validate before calling

// sanity-check the composed JQL before the API call
jqlQuery := strings.Join(query, " AND ")
if strings.TrimSpace(jqlQuery) == "" || strings.Count(jqlQuery, "(") != strings.Count(jqlQuery, ")") {
    return fmt.Errorf("refusing to send unbalanced/empty JQL: %q", jqlQuery)
}

Try / catch

result, err := widget.IssuesFor(ctx, username, jql)
if err != nil {
    if strings.Contains(err.Error(), "JIRA search failed") {
        log.Printf("search/jql endpoint failed: %v - check token/JQL/Atlassian status", err)
        // optional: fall back to legacy /rest/api/3/search
    }
    return err
}

Prevention

When it happens

Trigger: IssuesFor -> searchWithNewAPI receives a non-2xx or transport error from /rest/api/3/search/jql: 401/403 (bad token), 400 (malformed JQL), 429, or network failure to api.atlassian.com.

Common situations: Expired/revoked Jira API tokens, JQL composed from username conversion plus user JQL that is syntactically invalid, Atlassian deprecating/changing the search/jql endpoint, corporate proxy blocking api.atlassian.com.

Related errors


AI-assisted analysis of wtfutil/wtf@bb838c1ccb (2026-09-03). Data as JSON: /api/errors/c0f6b3e341760a24. Report an issue: GitHub.