Skip to content

JIRA cloud issue creation and availability issue#448

Merged
ralphbean merged 1 commit intorelease-engineering:mainfrom
Bala-Sakabattula:fixes
Apr 2, 2026
Merged

JIRA cloud issue creation and availability issue#448
ralphbean merged 1 commit intorelease-engineering:mainfrom
Bala-Sakabattula:fixes

Conversation

@Bala-Sakabattula
Copy link
Copy Markdown
Collaborator

Created this PR for solving the following issue:

  1. After jira cloud issue creation instantly if you search for through JQL it won't return so for that we have used GET call as an alternative if the key is present in cache or in snowflake but not in JQL ...

  2. As previously we are logging issue Id but it isn't that useful so we are now chnaged to the log the JQL contents it will help to debug in better way.

  3. Updated to use displayName instead of name in _update_Assignee and check_comments_for_duplicate

Copy link
Copy Markdown
Collaborator

@webbnh webbnh left a comment

Choose a reason for hiding this comment

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

I'm OK with this as is, since we very much want to stop creating duplicates, but I have a couple of concerns (and a bunch of suggestions).

First, I recommend changing the focus of _get_existing_jira_issue_query() (and its name) so that it returns the key list and not the JQL -- the caller can produce the JQL easily enough, and returning a naked tuple is something best to avoid unless there's a compelling need.

Second, you modified two access to use displayName, but their respective approaches are inconsistent...which is fine if it's justified, but my instinct is that one of them is "right" and one is "wrong" -- and I don't know which is which....

So, perhaps we could merge this and then you could polish it in a follow-up PR.

Comment on lines +319 to 322
issue_keys, jql = _get_existing_jira_issue_query(issue)
if not jql:
return None
results: ResultList[JIssue] = client.search_issues(jql)
Copy link
Copy Markdown
Collaborator

@webbnh webbnh Apr 2, 2026

Choose a reason for hiding this comment

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

I don't think it's worthwhile to return a tuple. Instead, I suggest refocusing (and renaming) the subroutine and moving the query creation to the caller:

Suggested change
issue_keys, jql = _get_existing_jira_issue_query(issue)
if not jql:
return None
results: ResultList[JIssue] = client.search_issues(jql)
issue_keys = _get_existing_jira_issue_keys(issue)
if not issue_keys:
return None
jql = f"key in ({','.join(issue_keys)})
results: ResultList[JIssue] = client.search_issues(jql")

Comment on lines 323 to +326
if not results:
# It is _possible_ that the downstream issue exists (i.e., we did hit
# it in the cache or in Snowflake) but the Jira search cannot find it.
# (This happens when the issue has been archived.) Fail as gracefully
# as we can here, but our caller will probably create it again.
log.warning(
"Previously-existing downstream issue %s not found for upstream issue %s.",
issue.id,
issue.url,
)
return None
# JQL/search index can lag right after create, or hide archived issues.
# Resolve by issue key (direct GET) before giving up and duplicating.
results = ResultList[JIssue]()
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

You don't need to assign results here -- the if statement at line 323 ensures that it's an empty list already.

Comment on lines +327 to +339
for key in issue_keys:
try:
found = client.issue(key)
except JIRAError:
continue
log.info(
"JQL missed key %s for upstream %s; using direct issue fetch.",
key,
issue.url,
)
results = ResultList[JIssue]((found,))
break
if not results:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Rather than using if not results, I think it would be more graceful to just use else -- if we don't break out of the for loop, then we'll execute the else block.

Comment on lines +463 to +465
author_label = getattr(author, "displayName", None) or getattr(
author, "name", None
)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Alternatively,

Suggested change
author_label = getattr(author, "displayName", None) or getattr(
author, "name", None
)
author_label = getattr(author, "displayName", getattr(author, "name", None))

Comment on lines +1160 to +1162
update = (
issue.downstream.get("owner") != existing.fields.assignee.displayName
)
Copy link
Copy Markdown
Collaborator

@webbnh webbnh Apr 2, 2026

Choose a reason for hiding this comment

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

Why do we use getattr() to access displayName at line 463 but use a direct access here? (Is one of the two "wrong"?)

Comment on lines 289 to +290

def _q(keys):
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Access to this function is scoped to this function, so you don't need the underscore prefix on the name.

Comment on lines +357 to +361
if x["issue_side_effect"] is not None:
mock_client.issue.side_effect = x["issue_side_effect"]
else:
mock_client.issue.side_effect = None
mock_client.issue.return_value = mock_issue_1
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I believe that you can simplify this:

Suggested change
if x["issue_side_effect"] is not None:
mock_client.issue.side_effect = x["issue_side_effect"]
else:
mock_client.issue.side_effect = None
mock_client.issue.return_value = mock_issue_1
mock_client.issue.side_effect = x["issue_side_effect"]
if not x["issue_side_effect"]:
mock_client.issue.return_value = mock_issue_1

or possibly even

Suggested change
if x["issue_side_effect"] is not None:
mock_client.issue.side_effect = x["issue_side_effect"]
else:
mock_client.issue.side_effect = None
mock_client.issue.return_value = mock_issue_1
if not mock_client.issue.side_effect := x["issue_side_effect"]:
mock_client.issue.return_value = mock_issue_1

@ralphbean ralphbean enabled auto-merge (squash) April 2, 2026 18:10
@ralphbean ralphbean merged commit bb89d28 into release-engineering:main Apr 2, 2026
6 checks passed
@Bala-Sakabattula Bala-Sakabattula mentioned this pull request Apr 5, 2026
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.

3 participants