-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: replace jira client #838
Merged
urielsalis
merged 76 commits into
mojira:master
from
jkazimierczak:fix/replace-jira-client
Feb 25, 2025
Merged
fix: replace jira client #838
urielsalis
merged 76 commits into
mojira:master
from
jkazimierczak:fix/replace-jira-client
Feb 25, 2025
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Purpose
Replaces obsolete
net.rcarz.jiraclient
API client with custom API client that's compatible with Jira Cloud API v2.TLDR
Approach
New API Client
The main point of integration between Arisa and the Jira API lies in the
infrastructure
directory - this is where all of the mapping happens between what API returns and what the Arisa operates on (Mappers.kt
andFunctions.kt
). The initial idea was to identify all usages of old client, and provide new Jira API Client that has the feature-parity of the old client for all usages within the project, so quick drop-in replacement can be done where needed.It quickly turned out that the old client was pretty coupled (internally) to the API models and operations performed on them, which expanded the surface of used endpoints by quite a bit. The new client is decoupled in this regard, as all used API models are defined as serializable dataclasses and do not depend on the API client.
Given the above, this allowed to introduce the new client with minimal modifications to the modules themselves.
Identify used properties within domain models
Current domain objects are quite lengthy in terms of properties they have, with
domain.Issue
being probably the biggest one. Given that the requirements handed to us prioritized Privacy and PrivateDuplicate modules the most, we began to identify which of the properties were actually needed. To refrain from rewriting or removing all present modules, we introduced Cloud variants of the domain models, which allowed to minimize the scope of the codebase migration to just required modules.This was followed by modifying the
Module
interface to allow to specify issue type through generic type. To not break the existing modules, theModule
interface extends the generic interface with the oldIssue
domain model, and new Cloud-compatible modules useCloudIssue
domain model:Although I'm not a fan of comments in code, I left the unused properties commented out, to easily see at glance which properties were previously needed and might be needed in the future if the rest of modules are going to be adapted to the Cloud Jira API. Similar stand true for
Mappers.kt
.Modify module registries
As the interface was modified, registries and existing non-cloud modules disallowed us from compiling the Arisa. We've decided to remove the registrations of the non-compatible modules from the InstantRegistry, and comment out the Delayed and Linked registries (yet again, I despise the comments as a solution in this case).
API V2, V3 and ADF
Jira Cloud API exists in two versions, which have the same collection of operations. The main notable difference is that V3 uses Atlassian Document Format (ADF) in:
To minimize the work needed we've decided to go with API V2, which uses the markdown, as it was the case for old Jira 9.12.x API. This required minimal changes though, for example mentioning users is done purely through accountid and syntax slightly differed.
The current state of the models being decoupled from the API operations should allow easier introduction of ADF libraries provided by Atlassian (currently offered for Kotlin, Java and JavaScript). I haven't yet delved into how they work, but it should be possible to integrate the serialization/deserialization of ADF through custom serializers if necessary (similar to how we needed to provide serializers for
URI
andOffestDateTime
classess).Config changes
The new API switched authentication from username and password to email and API token. That means that Arisa
local.yml
config needs to have these specified:Cloud Jira operates on account IDs instead of usernames, so it's necessary to specify the
accountId
of the user that is operating as Arisa bot. It should be possible to retrieve theaccountId
for Arisa through opening this endpoint in the browser:https://jira-connection.atlassian.net/rest/api/2/user/picker?query=Arisa
FluentUpdate and FluentTransition
Previous library provided classes that allowed to fluently specify field updates and transitions. We've provided provided classes (
apiclient.builders
) that allow to construct the JSON in the same fluent fashion, but with slightly different syntax.The example usages can be seen in
Functions.kt
and tests.Tests
Introduction of the new client and new models are accompanied by the new test suite that test whether the deserialization of example API responses happens correctly and doesn't throw.
However, as a result of all modifications there were three test cases that didn't play nicely with modifications, namely:
We've decided to keep these tests disabled for now, as the registry test will fail unless all modules are registered, while RemoveVersionModule tests were out of scope for now.
Future work
Migration of the existing modules should be rather easier given the groundwork this PR provides. Slight modifications might be necessary here and there though.
None of the prioritized modules seemed to use issue transitions. Although client has the methods to handle them, it's unknown at this point if they would work right away. In case of doubt, use
logNetworkRequests
debug config flag to see the endpoint, method and body of the HTTP requests,Rest of modules should be slowly ported according to the specified priority,
Switch username/display name usages to use account IDs instead.
Checklist
and
docs
folder