SamuelMuellerKMS opened a new issue, #9405:
URL: https://github.com/apache/devlake/issues/9405

   ### Search before asking
   
   - [x] I had searched in the 
[issues](https://github.com/apache/incubator-devlake/issues?q=is%3Aissue) and 
found no similar issues.
   
   
   ### What happened
   
   Since upgrading to a version that contains #8931 ("collect issues via search 
API to avoid kanban sub-filter exclusion"), no new rows are written to 
`_tool_jira_sprint_issues` / `sprint_issues`. Issues and sprints are collected 
correctly, but the relation between them is missing:
   
   - All sprints started after the upgrade have **zero** issues (every active 
sprint in our instance).
   - Issues collected before the upgrade keep their old sprint relations, which 
become stale when issues move between sprints.
   - `_tool_jira_issues.sprint_id` is `0` for all issues.
   
   Root cause:
   
   - `issue_collector.go` now uses `api/2/search` (Server) / `api/3/search/jql` 
(Cloud) with `filter = <boardFilterId>`.
   - `apiv2models/issue.go` → `Issue.ExtractEntities` still builds the sprint 
list **only** from `fields.sprint` and `fields.closedSprints`:
     ```go
     if i.Fields.Sprint != nil {
         sprints = append(sprints, i.Fields.Sprint.ID)
     }
     for _, sprint := range i.Fields.ClosedSprints {
         sprints = append(sprints, sprint.ID)
     }
     ```
   - `fields.sprint` and `fields.closedSprints` are only returned by the Agile 
API (`agile/1.0/board/{id}/issue`). The search API returns sprint membership 
only through the Sprint custom field (schema custom 
`com.pyxis.greenhopper.jira:gh-sprint`, e.g. `customfield_10004`).
   
   Raw data comparison from our instance (`_raw_jira_api_issues`):
   
   | collected | URL | `fields.sprint` / `fields.closedSprints` | Sprint custom 
field |
   |---|---|---|---|
   | before upgrade | `rest/agile/1.0/board/98/issue?...` | present | present |
   | after upgrade | `rest/api/2/search?expand=changelog&fields=*all&jql=filter 
= ...` | **absent in 100% of rows** | present |
   
   On Jira Server/DC the custom field value is an array of legacy strings:
   ```
   
["com.atlassian.greenhopper.service.sprint.Sprint@14e33bf4[activatedDate=2026-11-04T13:44:13.760+01:00,autoStartStop=false,completeDate=<null>,endDate=2026-11-18T13:30:00.000+01:00,goal=,id=2424,incompleteIssuesDestinationId=<null>,name=Team
 A Sprint 
42,rapidViewId=148,sequence=2376,startDate=2026-11-04T13:30:00.000+01:00,state=ACTIVE,synced=false]"]
   ```
   On Jira Cloud it is an array of objects with an `id` property.
   
   ### What do you expect to happen
   
   Sprint–issue relations are extracted for issues collected via the search 
API, i.e. `_tool_jira_sprint_issues` and `sprint_issues` contain every sprint 
listed in the issue's Sprint field, as before #8931.
   
   ### How to reproduce
   
   1. Jira Server/DC connection (likely Cloud as well), board scope with active 
sprints.
   2. Run a blueprint with a DevLake version that includes #8931.
   3. `SELECT COUNT(*) FROM _tool_jira_sprint_issues WHERE sprint_id = <active 
sprint id>;` → `0`
   4. Check the raw issue: `JSON_EXTRACT(data, '$.fields.sprint')` is `NULL`, 
while `JSON_EXTRACT(data, '$.fields.customfield_<sprint field id>')` contains 
the sprint.
   
   ### Anything else
   
   Suggested fix: in the issue extractor, resolve the Sprint custom field id 
from `_tool_jira_issue_fields` (`schema_custom = 
'com.pyxis.greenhopper.jira:gh-sprint'`), the same way story point / epic link 
fields are resolved, and parse it from `Fields.AllFields` when `fields.sprint` 
/ `fields.closedSprints` are empty:
   - element is an object → take `id`
   - element is a string (Server legacy format) → parse `,id=(\d+),`
   
   Note: the Sprint custom field already contains both closed and current 
sprints, so it can fully replace `sprint` + `closedSprints`.
   
   Workaround we use in the meantime: a SQL script run after each sync that 
parses the Sprint custom field from `_raw_jira_api_issues` and fills 
`_tool_jira_sprint_issues` / `sprint_issues`.
   
   
   ### Version
   
   v1.0.3-beta19@210dcd4
   
   ### Are you willing to submit PR?
   
   - [ ] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of 
Conduct](https://www.apache.org/foundation/policies/conduct)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to