Skip to content

Tweak Jira assignee matching#377

Merged
ralphbean merged 2 commits intomainfrom
ldap-redux
Oct 14, 2025
Merged

Tweak Jira assignee matching#377
ralphbean merged 2 commits intomainfrom
ldap-redux

Conversation

@webbnh
Copy link
Copy Markdown
Collaborator

@webbnh webbnh commented Oct 8, 2025

We're seeing some odd behavior for certain Issue assignees. The Jira lookup based on the RH email address returned by the LDAP search is returning multiple assignees in these cases. The sync2jira code then arbitrarily selects the first one, since they are all supposed to match the email address. But, the selected user doesn't actually match the upstream assignee, and it seems to be the same individual in all the cases...so, it looks like Jira is returning all possible assignees -- not just the ones with matching email addresses -- and the list is probably in sorted order, and it results in a unique hit for all searches.

The principal purpose of this PR is to make two changes: to enhance the logging so that we can get better insight into what's actually happening, and to provide some validation of the Jira response.

The code which matches the up- and downstream assignees is reordered slightly, so that it checks for a unique match before checking for multiple matches. In the event that multiple possible assignees are returned, the code searches for one which matches the target email address. Since all the returned assignees should match the target, this code should simply select the first one; however, if Jira is misbehaving as I expect, this will ensure that we don't try to assign the downstream issue to a non-match. This change also includes enhancements to the logging which, hopefully, will be illuminating. And, because of this additional checking, we need additional support from the mocking in the unit tests.

In addition, this PR reworks the LDAP lookup's error handling, so that, hopefully, we'll be properly notified of real errors without false positives for "normal" cases (which will "quiet" the logging a bit).

  • The existing code conflates LDAP searches which "miss" (which produce no results) with requests that fail. This change configures the LDAP client to report errors by exception. Exceptions will be logged as ERROR's; and, now, searches which are otherwise successful but which return no result will be logged as INFO's.
  • The logging calls in the lookup code have been reworked to replace f-strings with format arguments, which allows the string formatting to be deferred and skipped altogether for logging which is disabled (such as DEBUG-level during production operation).
  • These changes require two tweaks to the unit tests, since they check the LDAP connection parameters and the log messages.

@webbnh webbnh requested review from Zyzyx and ralphbean as code owners October 8, 2025 00:36
Copy link
Copy Markdown
Member

@ralphbean ralphbean left a comment

Choose a reason for hiding this comment

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

LGTM!

@ralphbean ralphbean merged commit cd31a1d into main Oct 14, 2025
6 checks passed
@ralphbean ralphbean deleted the ldap-redux branch October 14, 2025 19:25
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.

2 participants