Skip to content

fix(jira): extract sprint relations from the Sprint custom field - #9410

Merged
klesh merged 1 commit into
apache:mainfrom
Goldloli:fix-jira-sprint-customfield
Nov 19, 2026
Merged

klesh merged 1 commit into
apache:mainfrom
Goldloli:fix-jira-sprint-customfield

Conversation

@Goldloli

Copy link
Copy Markdown
Contributor

⚠️ Pre Checklist

  • I have read through the Contributing Documentation.
  • I have added relevant tests.
  • I have added relevant documentation.
  • I will add labels to the PR, such as pr-type/bug-fix, pr-type/feature-development, etc.

Summary

Since #8931 the Jira issue collector uses the search API (api/2/search / api/3/search/jql). Responses from that API no longer include fields.sprint / fields.closedSprints — sprint membership only remains in the Sprint custom field (schema com.pyxis.greenhopper.jira:gh-sprint, e.g. customfield_10004). As a result _tool_jira_sprint_issues / sprint_issues get no rows for newly synced issues, and stale relations are never refreshed.

This PR restores the relations:

  • ExtractIssues / ExtractEpics resolve the Sprint custom field id from _tool_jira_issue_fields via its stable schema_custom value (the field is frequently renamed, e.g. to "Sprint" in any language).
  • During extraction, ids parsed from that custom field in Fields.AllFields are merged (deduplicated) with the structured fields.sprint / fields.closedSprints ids:
    • Jira Cloud: array elements are objects → take id;
    • Jira Server/DC: array elements are legacy strings com.atlassian.greenhopper.service.sprint.Sprint@hash[...,id=2424,...] → parse id=(\d+);
    • single (non-array) values are handled the same way.
  • When the Sprint field has not been collected, behavior is unchanged (structured fields only).

The denormalized sprint_id / sprint_name columns on _tool_jira_issues are intentionally left as-is (still sourced from fields.sprint) to keep this PR focused on the relation tables; that can be a follow-up.

Does this close any open issues?

Closes #9405

Screenshots

N/A (backend extraction change)

Other information

Verification (macOS, Go 1.27):

  • go test ./plugins/jira/tasks/ -run TestExtractIssuesSprintCustomField -v — 4/4 pass, covering: Server legacy strings, Cloud objects, merge+dedupe with structured fields, and the disabled-path fallback (unresolved field id keeps old behavior):
    --- PASS: TestExtractIssuesSprintCustomField (0.00s)
        --- PASS: .../server_legacy_sprint_strings_are_parsed
        --- PASS: .../cloud_sprint_objects_are_parsed
        --- PASS: .../custom_field_is_merged_with_structured_sprint_fields_without_duplicates
        --- PASS: .../empty_sprint_field_id_keeps_structured_behavior
    
  • go test ./plugins/jira/tasks/... ./plugins/jira/models/... — all ok
  • golangci-lint run plugins/jira/tasks/... (v2.15.0, same as CI) — 0 issues
  • go mod tidy — no diff
  • e2e impact reviewed: existing e2e fixtures contain no gh-sprint row in _tool_jira_issue_fields, so the new path stays inactive there and snapshots are unchanged; the legacy-string fixture in the new unit test uses the exact format quoted in the issue from a real Server/DC instance.

Issues collected through the search API (apache#8931) no longer carry
fields.sprint/fields.closedSprints, so no rows were written to
_tool_jira_sprint_issues / sprint_issues for newly synced issues.
Sprint membership is still present in the Sprint custom field, so
resolve its field id from _tool_jira_issue_fields via the stable
schema_custom value com.pyxis.greenhopper.jira:gh-sprint and merge the
parsed ids into the extracted sprint relations.

Jira Cloud returns an array of objects with an "id" property; Jira
Server/DC returns legacy strings like
"com.atlassian.greenhopper.service.sprint.Sprint@hash[...,id=2424,...]"
which are parsed for the id. When the Sprint field is not collected the
extractor keeps the previous structured-fields-only behavior.
@klesh
klesh merged commit b7f13e5 into apache:main Nov 19, 2026
10 checks passed
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.

[Bug][Jira] Sprint–issue relations no longer extracted since issues are collected via search API (#8931)

2 participants