Skip to content

fix: automation API response types don't match actual API #81

@rianjs

Description

@rianjs

Bug: Automation API types don't match actual Jira Cloud API responses

Discovery

Integration testing against monitproduct.atlassian.net revealed that the automation command types were built from API documentation that doesn't match the actual response format. All automation commands silently fail — they get 200 OK but can't parse the responses.

Mismatches Found

1. List/Summary endpoint (GET /rule/summary)

Actual response:

{
  "links": {"self": null, "next": null, "prev": null},
  "data": [
    {"uuid": "018aed44-...", "name": "...", "state": "ENABLED", ...}
  ]
}

Our type expects:

type AutomationRuleSummaryResponse struct {
    Total  int                     `json:"total"`
    Values []AutomationRuleSummary `json:"values"`  // should be "data"
    Next   string                  `json:"next"`     // should be "links.next"
}
  • data not values
  • links.next not top-level next
  • No total field
  • Rules identified by uuid not numeric id

2. Get single rule endpoint (GET /rule/{uuid})

Actual response:

{
  "rule": {
    "name": "...",
    "state": "ENABLED",
    "uuid": "018aed44-...",
    "trigger": { "component": "TRIGGER", "type": "...", ... },
    "components": [ ... ],
    "ruleScopeARIs": ["ari:cloud:jira:..."],
    "labels": [],
    ...
  },
  "connections": [...]
}

Our type expects: Rule at top level with json:"id" and json:"ruleKey"

Key differences:

  • Rule nested under "rule" key, not at top level
  • ID field is uuid not idno numeric ID exists
  • Trigger is a separate field from components array
  • Projects represented as ruleScopeARIs (ARIs), not projects array
  • No tags field (we have one)

3. Rule summary objects

Actual fields:

{
  "uuid": "018aed44-eda8-7f38-8dc8-4b6588c10073",
  "name": "ON/MON: Unblock Onboarding Tickets",
  "state": "ENABLED",
  "description": "...",
  "authorAccountId": "...",
  "actorAccountId": "...",
  "created": 1696197832.104,
  "updated": 1700430538.092,
  "labels": [],
  "ruleScopeARIs": ["ari:cloud:jira:..."]
}

Our type maps: IDjson:"id" (doesn't exist), UUIDjson:"ruleKey" (should be uuid)

Impact

  • jtk auto list — returns "No automation rules found" (parses data as nil values)
  • jtk auto get <id> — likely fails or returns empty (rule nested under "rule")
  • jtk auto export <id> — returns raw JSON so may partially work
  • jtk auto update — may send wrong format
  • jtk auto create — may send wrong format
  • jtk auto enable/disable — unknown, state endpoint format not yet verified

Fix Required

  1. AutomationRuleSummaryResponse — use Data (json:"data") and nested Links struct
  2. AutomationRuleSummary — use UUID (json:"uuid") as primary ID, drop json:"id"
  3. AutomationRule — wrap in {"rule": ...} envelope for GET responses
  4. All commands that display IDs — use UUID instead of numeric ID
  5. Pagination — follow links.next instead of top-level next
  6. Verify create/update/state endpoints accept the same format they return

Files to modify

  • tools/jtk/api/automation_types.go — fix all type definitions
  • tools/jtk/api/automation.go — fix response parsing, pagination
  • tools/jtk/api/automation_test.go — update mock responses to match real API
  • tools/jtk/internal/cmd/automation/list.go — use UUID for ID column
  • tools/jtk/internal/cmd/automation/get.go — use UUID, handle envelope
  • tools/jtk/internal/cmd/automation/export.go — may need to unwrap envelope
  • tools/jtk/internal/cmd/automation/update.go — use UUID
  • tools/jtk/internal/cmd/automation/enable.go — use UUID
  • All command tests — update accordingly

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions