Skip to content

Epic: Migrate jira-python client from REST API v2 to v3 (ADF) #96

Open

Description

@f3rdy

Epic: Migrate jira-python client from REST API v2 to v3 (ADF)

Type: Epic / tracking issue · Part of the v2.0 roadmap (#17)

Motivation

budjira constructs its jira-python client without options={"rest_api_version": "3"}
(budjira/core/jira_client.py:72), so it defaults to REST API v2. Under v2, Jira
Cloud renders rich-text fields with the legacy wiki-markup renderer, so Markdown
that authors naturally write (headings, checkboxes, bullet lists) renders as garbage.
This was reported and worked around in #95.

The proper, long-term fix is to move the client to v3 and represent rich text as
ADF (Atlassian Document Format). This epic tracks that migration.

⚠️ Blast radius — read before starting

Flipping rest_api_version to "3" is a one-line change with a tool-wide effect.
In v3, every rich-text field is an ADF JSON object (nested dict), not a string, on
both read and write. A naive flip breaks reads first: Issue.description
(budjira/models/issue.py:82) and Comment.body (budjira/models/issue.py:51) are
typed str and would receive ADF dicts on every read of every issue/comment,
raising Pydantic ValidationError immediately.

This affects far more than the description field. Confirmed touch set:

Writes (currently send strings; v3 needs ADF)

  • budjira/services/issues.py:178 — create: fields["description"]
  • budjira/services/issues.py:295 — update: update_fields["description"]
  • budjira/services/comments.py:33 — add_comment(issue_key, body)
  • budjira/services/worklogs.py:53-57 — worklog comment
  • budjira/services/links.py:110 — issue-link comment.body
  • budjira/models/custom_field.py:113-114 — rich-text (multi-line) custom fields (config-dependent)

Reads / parses (currently expect strings; v3 returns ADF dicts)

  • budjira/models/issue.py:153 — _parse_basic_fields: fields.description
  • budjira/models/issue.py:292 — _parse_comments: c.body
  • budjira/services/comments.py:39, budjira/services/worklogs.py:112-113

Downstream string-assuming consumers (would crash / mis-render)

  • budjira/cli/show.py:150-154,170 — marker in issue.description, Markdown(...), print(comment.body)
  • budjira/cli/create.py:591-595 — description[:100], len(description)
  • budjira/utils/dor_validator.py:26,47-71 — regex ^## (.+)$ over the description string; ADF dict breaks the entire DoR gate

Not affected

  • Tempo REST paths (budjira/tempo/*, services/workflow.py, cli/tempo.py) — separate API, stay plain strings
  • Epic-link / parent handling — IDs/keys, not rich text
  • summary — plain text in both v2 and v3

Existing conversion

Scope of this epic

  • Add a bidirectional ADF converter (text/Markdown → ADF on write; ADF → text on read), or adopt a maintained library
  • Enable rest_api_version="3" in the client (core/jira_client.py)
  • Convert all write paths listed above to ADF
  • Convert all read/parse paths; relax Issue.description / Comment.body model types and re-derive display text
  • Fix downstream string-assuming consumers (show.py, create.py, DoR validator)
  • Realign the DoR validator so create-time markers and rendered output agree under ADF
  • Comprehensive tests — failures here are runtime type errors, not compile-time, so coverage is critical across every read/write path
  • Verify no regression in search / show / worklog / epic flows

Estimated size

Moderate but not trivial: roughly 8 source files + one new converter module, heavily
test-worthy. This is deliberately not bundled into the #95 fix, which ships a contained
v2 Markdown→wiki workaround instead.

Related

Activity

  1. added
    refactoring
    epic
    on Jul 17, 2026
  2. f3rdy commented on Aug 13, 2026

    @f3rdy
    ContributorAuthor

    A prerequisite worth pulling into this epic, because the migration makes it sharper rather than
    moot.

    Since the #95 fix, markdown_to_wiki() is applied unconditionally to every description, on
    create (services/issues.py:180) and on update (:298). For an instance whose house format
    is wiki markup, that rewrites the author's input rather than helping it: a wiki ordered list
    (# item) matches the Markdown heading rule first and is emitted as h1. item. Measured on
    1.22.1 against a description with three ordered lists inside panel macros: twelve lines came back
    as h1. headings. The panels survive only because they happen to match no Markdown rule, so the
    current behaviour is "wiki markup works by luck, except where it doesn't".

    After the move to v3 there are three possible dialects an instance may expect - Markdown, legacy
    wiki markup, ADF - and which one applies is a property of the connection, not of the client
    version. If this epic introduces that property first, the migration can be adopted per connection
    instead of switched globally, and instances that live on wiki markup keep a way to send it
    verbatim.

    Related: #84 (per-connection settings), #82 (per-connection policy).

  3. f3rdy commented on Sep 20, 2026

    @f3rdy
    ContributorAuthor

    Context correction on my own comment above: budjira has no stake in which wire format a customer's Jira uses. The customer's project defines the format; budjira's job is to produce exactly that, byte for byte, and to make the result verifiable before the first write. The measurements below are about what breaks silently during the migration, not an argument for keeping v2.

    Measured 2026-09-20 (budjira v1.33.0, jira-python 3.10.5) on a Jira Cloud instance whose project (CLOUDFS) currently stores descriptions as wiki markup:

    1. The write path changes meaning, not just transport. Jira Cloud accepts a wiki-markup string on /rest/api/2/issue and converts it to ADF server-side. On v3 the same string is no longer converted — the team owning that project documented an issue of theirs that shipped with raw wiki markup rendered as literal text. Since issues there cannot be deleted and API comments cannot be edited, such a write is not repairable in place.

    2. Reads change shape. The same issue returns fields.description as a wiki string on v2 and as an ADF dict on v3. Anything treating descriptions as text needs an ADF-aware path; the Agile API stays string-based, so a mixed client sees both.

    3. Not all of v2 is still there. GET /rest/api/2/search?jql= answers 410 Gone on that instance, and jira-python already routes search through enhanced_search_issues -> search/jql. "v2 today" is therefore not a single coherent state.

    Suggestion: make the authored dialect an explicit, per-connection setting on both sides of the migration — whatever a customer prescribes (ADF, wiki, Markdown), budjira should be able to emit it without the caller hand-building JSON. #134 proposes the same switch for comments, #135 a dry-run that prints the outgoing payload, which is what makes "did we match the customer's format exactly?" answerable before an irreversible write.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    epicrefactoring

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions