Repository navigation
Bugfix/1855 jira deprecated endpoint - #1860
Conversation
Fixes wtfutil#1855 - Replace deprecated username-based queries with account ID conversion - Implement JQL conversion API using /rest/api/3/jql/pdcleaner endpoint - Add ConvertJQLWithUsername function to convert usernames to account IDs - Add jiraPostRequest method for POST requests with JSON payload - Update IssuesFor function to use converted account IDs instead of usernames - Maintain backward compatibility for existing username-based configurations This addresses JIRA Cloud API changes where usernames are no longer supported in favor of account IDs for user identification in JQL queries.
- Add UserIDCacheMap with thread-safe caching for username to account ID mappings - Implement 10-minute cache expiration to balance performance and data freshness - Add extractAccountIDFromJQL helper function for proper account ID extraction - Fix Get method to properly clean up expired cache entries - Add comprehensive test suite with 10 test cases covering: * Cache operations (set, get, expiration, cleanup) * Account ID extraction from various JQL formats * API integration with mock HTTP servers * Error handling for various failure scenarios * Cache hit/miss performance scenarios
JIRA deprecated the /rest/api/2/search and /rest/api/3/search endpoints,
causing 410 Gone errors. This commit implements a two-step API approach:
1. Use /rest/api/3/search/jql to retrieve issue IDs
2. Fetch full issue details via /rest/api/3/issue/{id} for each result
Key changes:
- Add searchWithNewAPI() method using /rest/api/3/search/jql endpoint
- Add getIssueByID() method for individual issue retrieval
- Implement UserIDCacheMap with thread-safe caching for username->accountID conversion
- Add ConvertJQLWithUsername() for JQL username to account ID conversion via /rest/api/3/jql/pdcleaner
- Improve error handling with detailed API response information
- Set result limit to 20 issues to balance performance and API call limits
- Add graceful error handling to continue processing if individual issues fail
This resolves the widget crashes and restores JIRA integration functionality
while maintaining backward compatibility with existing configurations.
Fixes wtfutil#1855
JIRA deprecated the /rest/api/2/search and /rest/api/3/search endpoints,
causing 410 "Gone" errors. This commit implements a two-step API approach:
1. Use /rest/api/3/search/jql to retrieve issue IDs
2. Fetch full issue details via /rest/api/3/issue/{id} for each result
Key changes:
- Add searchWithNewAPI() method using /rest/api/3/search/jql endpoint
- Add getIssueByID() method for individual issue retrieval
- Implement UserIDCacheMap with thread-safe caching for username->accountID conversion
- Add ConvertJQLWithUsername() for JQL username to account ID conversion via /rest/api/3/jql/pdcleaner
- Improve error handling with detailed API response information
- Set result limit to 20 issues to balance performance and API call limits
- Add graceful error handling to continue processing if individual issues fail
- Fix unit test to handle improved error message format
This resolves the widget crashes and restores JIRA integration functionality
while maintaining backward compatibility with existing configurations.
Fixes wtfutil#1855
|
@FelicianoTech how do we get this merged? would love to have this working again! |
|
This will make this next release. I’ll get to it very soon. |
|
@dfoulkes As far as you know, the PR shouldn't require any changes to:
right? |
|
@yak3d The plan is to have this merged and a new release published within the next 24 hours. |
|
@FelicianoTech, based on my assessment, the current state appears satisfactory. However, if you require any specific considerations regarding the caching element, please advise. I would like to remind users of this fix that modifications to a user ID will necessitate the cache duration to resolve; however, I assess this scenario as highly specialised, if not entirely improbable. |
|
This is definitely good enough for now. As this is a bugfix, kind of, I want to prioritize getting this merged. If there's any optimization to be done, we can always do it in a future PR. In the next 6 months I want to start a program where every module in WTF is reviewed for necessity, stability, bugs, security, and possible optimizations. We'll have time to improve, if it's even needed. This is a pretty sizable PR for an open-source bug fix. Thank you @dfoulkes for taking the time to contribute. I don't use Jira myself but I'm sure people are using it will really appreciate this work. |
fixes #1855
This pull request introduces a new caching mechanism and logic for converting JIRA usernames to account IDs, and updates the search flow to use the new JIRA API v3 endpoints. It also adds unit tests for the new caching and conversion logic. These changes improve the efficiency and reliability of user-based JIRA queries, reduce redundant API calls, and enhance error handling and test coverage.
JIRA Username-to-AccountID Conversion and Caching:
UserIDCacheMap) to store mappings from JIRA usernames to account IDs, with expiration logic to avoid unnecessary API requests.ConvertJQLWithUsernamemethod, which converts a JQL query containing a username to use the corresponding account ID, leveraging the cache and calling the/rest/api/3/jql/pdcleanerendpoint when needed.extractAccountIDFromJQL,Set,Get,Clear).JIRA API Usage and Search Improvements:
IssuesFormethod to use the new API v3 search endpoint (/rest/api/3/search/jql) and fetch full issue details by ID, improving compatibility and future-proofing.Testing and Reliability:
client_test.goto cover the caching logic, JQL conversion, error cases, and integration with mocked JIRA endpoints, ensuring robust and predictable behaviour.