Skip to content

Conversation

justin-tahara
Copy link
Contributor

@justin-tahara justin-tahara commented Sep 1, 2025

Description

[Provide a brief description of the changes in this PR]
There is a new issue where the existing search endpoints did not append a /jql rather it was part of the argument. This PR aims to fix this issue that some customers are hitting as Atlassian aims to deprecate and remove the old API.

How Has This Been Tested?

[Describe the tests you ran to verify your changes]
Ran locally.

Backporting (check the box to trigger backport action)

Note: You have to check that the action passes, otherwise resolve the conflicts manually and tag the patches.

  • This PR should be backported (make sure to check that the backport attempt succeeds)
  • [Optional] Override Linear Check

Summary by cubic

Switch Jira issue search to the new /rest/api/{version}/search/jql endpoint to fix failures caused by Atlassian deprecating the old search API. This restores JQL search for affected customers without changing behavior.

  • Bug Fixes
    • Route searches through a new _custom_search_issues using /search/jql.
    • Preserve jql, startAt, maxResults, and fields handling; return Issue objects.
    • Add warning and temporary fallback to jira_client.search_issues on 410.
    • Validate responses and surface errors via response.raise_for_status().

* feat: JIRA support for custom JQL filter (#5164)

* jira jql support

* jira jql fixes

* Address comment

---------

Co-authored-by: sktbcpraha <131408565+sktbcpraha@users.noreply.github.com>
@justin-tahara justin-tahara requested a review from a team as a code owner September 1, 2025 19:47
Copy link

vercel bot commented Sep 1, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
internal-search Ready Ready Preview Comment Sep 1, 2025 7:51pm

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Greptile Summary

This PR fixes a breaking change in Atlassian's Jira API where the deprecated /rest/api/{version}/search endpoint is being replaced with /rest/api/{version}/search/jql. The change introduces a custom search function _custom_search_issues that directly calls the new JQL endpoint while maintaining compatibility with the existing JiraConnector interface.

The implementation replaces the call to jira_client.search_issues() with the new custom function on line 94. The _custom_search_issues function (lines 106-164) performs direct HTTP requests to the new endpoint, constructs Issue objects manually, and includes fallback logic to handle 410 status codes by attempting the old endpoint. This approach preserves the existing interface while addressing the immediate customer issue caused by Atlassian's API deprecation.

The change fits into the existing codebase by maintaining the same method signature and return types as the original search_issues method, ensuring that all existing code that depends on this functionality continues to work without modification. The implementation follows the repository's principle of not overengineering by providing a targeted fix rather than a complete refactoring of the Jira integration.

Confidence score: 3/5

  • This PR addresses an urgent API deprecation issue but has several implementation concerns that could cause problems
  • Score reflects the direct HTTP approach bypassing JIRA client features and potentially ineffective fallback logic
  • Pay close attention to the custom search implementation and error handling in _custom_search_issues function

1 file reviewed, 1 comment

Edit Code Review Bot Settings | Greptile

Comment on lines +142 to +150
if response.status_code == 410:
# Fallback to old method if needed (though it should fail now)
logger.warning("JQL endpoint returned 410, falling back to old search method")
return jira_client.search_issues(
jql_str=jql_str,
startAt=startAt,
maxResults=maxResults,
fields=fields,
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: The fallback to the old search method may not work since the old endpoint is deprecated. Consider logging this as an error and failing fast instead of attempting the deprecated call.

@justin-tahara
Copy link
Contributor Author

Closing in favor of: #5309

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 1 file

React with 👍 or 👎 to teach cubic. You can also tag @cubic-dev-ai to give feedback, ask questions, or re-run the review.

# Convert the response to Issue objects
issues = []
for issue_data in data.get("issues", []):
issue = Issue(jira_client, issue_data)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorrect Issue instantiation; pass options/session and raw so fields are populated correctly.

Prompt for AI agents
Address the following comment on backend/onyx/connectors/jira/connector.py at line 158:

<comment>Incorrect Issue instantiation; pass options/session and raw so fields are populated correctly.</comment>

<file context>
@@ -98,6 +103,67 @@ def _perform_jql_search(
+    # Convert the response to Issue objects
+    issues = []
+    for issue_data in data.get(&quot;issues&quot;, []):
+        issue = Issue(jira_client, issue_data)
+        # Ensure the issue has the necessary attributes
+        if not hasattr(issue, &quot;key&quot;) and &quot;key&quot; in issue_data:
</file context>
Suggested change
issue = Issue(jira_client, issue_data)
issue = Issue(jira_client._options, jira_client._session, raw=issue_data)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant