Skip to content

feat(jira): read a ticket and its comments from Jira Cloud - #42

Merged
Bakhomious merged 1 commit into
mainfrom
step/jira-client
Nov 4, 2026
Merged

Bakhomious merged 1 commit into
mainfrom
step/jira-client

Conversation

@Bakhomious

Copy link
Copy Markdown
Contributor

What

Step jira-client (plan row 65), the second of the three Jira steps (decision 58):

  • internal/jira/client.go: Client{HTTP, Site, Email, Token} and Ticket(ctx, key):
    • takes a key in any case, but only as a project's key, a dash and a number, so that it can't change the address, and sends it in capitals;
    • reads the site's cloud ID from https://<site>/_edge/tenant_info without a login, takes it only as a UUID, in its usual form;
    • sends the email and token to api.atlassian.com/ex/jira/<cloudId>/rest/api/3/... alone, asking for the fields that baton shows (summary,issuetype,status,parent,description,subtasks,issuelinks);
    • reads the comments with orderBy=created, a page at a time, until it has total or a page comes empty;
    • reads at most 16 MiB of an answer;
    • on a refusal: the status plus Jira's errorMessages or the gateway's message, or the status alone when the answer isn't JSON.
  • Tests against a fake Jira (httptest TLS server, a transport that sends each host to it, routes by host): DEMO-1 and DEMO-6 through to their Markdown goldens, page counts, an overstated total, the 16 MiB edge both ways, bad keys with no request sent, a wrong token, a missing ticket, a proxy's page, refused comments, a bad cloud ID, offline, a bad site, a cancelled context.
  • docs/plan.md: fact 41 (tenant_info), decision 59, rows jira-text Done (feat(jira): show a ticket as Markdown #41) and jira-client In review (feat(jira): read a ticket and its comments from Jira Cloud #42), the design's Jira paragraph and Sources.

Checks

  • mise run check green; internal/jira coverage 100%, total 99.4%.
  • Probes: 70 mutants of client.go, all caught (two rewritten after they didn't build).
  • Smoke: a throwaway test drove the client against the fake: demo-1 read DEMO-1 in 4 requests (tenant, ticket, 2 comment pages), and the errors read as read DEMO-99: 404 Not Found: Issue does not exist or you do not have permission to see it., read DEMO-1: 401 Unauthorized: Unauthorized, read the cloud ID of example.atlassian.net: 503 Service Unavailable.

Not checked yet

No real Jira call: whether tenant_info answers without a login and the gateway's 401 body shape wait for a live check, which the user asked to be asked about again when the jira step's code is ready.

Next: jira (config section, the Keychain read, baton jira <KEY>).

internal/jira's Client reads a ticket, with the fields that baton shows,
and all its comments, oldest first, through Atlassian's gateway with the
user's email and scoped token. It reads the site's cloud ID from the
site's tenant_info without a login, so that the token goes to the
gateway alone. It checks the key and the cloud ID, reads at most 16 MiB
of an answer, and gives Jira's messages when Jira refuses (decision 59,
fact 41).
@sonarqubecloud

sonarqubecloud Bot commented Nov 4, 2026

Copy link
Copy Markdown

@Bakhomious
Bakhomious merged commit 7f6db6d into main Nov 4, 2026
3 checks passed
@Bakhomious
Bakhomious deleted the step/jira-client branch November 4, 2026 20:23
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.

1 participant