Skip to content

Commit 3c4b3c5

Browse files
committed
don't rely on api version for parsing issues and separate cloud and dc versions
1 parent 64bee4c commit 3c4b3c5

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

backend/onyx/connectors/jira/connector.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949

5050
ONE_HOUR = 3600
5151

52-
JIRA_API_VERSION = os.environ.get("JIRA_API_VERSION") or "3"
5352
_JIRA_SLIM_PAGE_SIZE = 500
5453
_JIRA_FULL_PAGE_SIZE = 50
5554

@@ -113,11 +112,11 @@ def process_jira_issue(
113112
)
114113
return None
115114

116-
description = (
117-
issue.fields.description
118-
if JIRA_API_VERSION in ("2", "3")
119-
else extract_text_from_adf(issue.raw["fields"]["description"])
120-
)
115+
if isinstance(issue.fields.description, str):
116+
description = issue.fields.description
117+
else:
118+
description = extract_text_from_adf(issue.raw["fields"]["description"])
119+
121120
comments = get_comment_strs(
122121
issue=issue,
123122
comment_email_blacklist=comment_email_blacklist,

backend/onyx/connectors/jira/utils.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
PROJECT_URL_PAT = "projects"
2020
JIRA_API_VERSION = os.environ.get("JIRA_API_VERSION") or "2"
21+
JIRA_CLOUD_API_VERSION = os.environ.get("JIRA_CLOUD_API_VERSION") or "3"
2122

2223

2324
def best_effort_basic_expert_info(obj: Any) -> BasicExpertInfo | None:
@@ -85,7 +86,7 @@ def build_jira_client(credentials: dict[str, Any], jira_base: str) -> JIRA:
8586
return JIRA(
8687
basic_auth=(email, api_token),
8788
server=jira_base,
88-
options={"rest_api_version": JIRA_API_VERSION},
89+
options={"rest_api_version": JIRA_CLOUD_API_VERSION},
8990
)
9091
else:
9192
return JIRA(
@@ -119,11 +120,10 @@ def get_comment_strs(
119120
comment_strs = []
120121
for comment in issue.fields.comment.comments:
121122
try:
122-
body_text = (
123-
comment.body
124-
if JIRA_API_VERSION == "2"
125-
else extract_text_from_adf(comment.raw["body"])
126-
)
123+
if isinstance(comment.body, str):
124+
body_text = comment.body
125+
else:
126+
body_text = extract_text_from_adf(comment.raw["body"])
127127

128128
if (
129129
hasattr(comment, "author")

backend/tests/unit/onyx/connectors/jira/test_jira_large_ticket_handling.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def mock_issue_large() -> MagicMock:
6868

6969
@pytest.fixture
7070
def mock_jira_api_version() -> Generator[Any, Any, Any]:
71-
with patch("onyx.connectors.jira.connector.JIRA_API_VERSION", "2"):
71+
with patch("onyx.connectors.jira.utils.JIRA_CLOUD_API_VERSION", "3"):
7272
yield
7373

7474

0 commit comments

Comments
 (0)