JIRA Forge: Trigger Event Description does not match JIRA ticket description

Hi,
I am working with JIRA Forge and using these two trigger events, avi:jira:updated:issue and avi:jira:created:issue, to listen to JIRA issues when they create/update. For some reason, the event Description in the payload never matches the JIRA description ticket I create (attached JSON response).

The payload description is always “Tasks track small, distinct pieces of work.” But my JIRA ticket description has this instead after the ticket is created: “This is the new description”

I also tried getting the issue details directly from the rest API and got the same results: route/rest/api/3/issue/${event.issue.id}

{
  "issue": {
    "id": "10014",
    "key": "PZ-15",
    "fields": {
      "summary": "Test email notification",
      "issuetype": {
        "self": "https://dan.atlassian.net/rest/api/2/issuetype/10001",
        "id": "10001",
        "description": "Tasks track small, distinct pieces of work.",
        "iconUrl": "https://dan.atlassian.net/rest/api/2/universal_avatar/view/type/issuetype/avatar/10318?size=medium",
        "name": "Task",
...
  scopes:
    - storage:app
    - read:comment:jira
    - read:comment.property:jira
    - read:group:jira
    - read:project:jira
    - read:project-role:jira
    - read:role:jira
    - read:user:jira
    - read:issue:jira
    - read:issue-type:jira
    - read:status:jira
    - read:avatar:jira
    - read:field:jira
    - write:comment:jira
    - read:issue-meta:jira
    - read:issue-security-level:jira
    - read:issue.vote:jira
    - read:issue.changelog:jira
    - read:field-configuration:jira
modules:
  trigger:
    - key: issue-tracker-trigger
      function: main
      events:
        - avi:jira:created:issue
        - avi:jira:updated:issue
  function:
    - key: main
      handler: index.run

JIRA Ticket:

Could anyone please shed a light on this? Thank you so much in advance.

Hi @DJO , welcome to the Atlassian Developer Community!

"description": "Tasks track small, distinct pieces of work.",

This description you are referring to is not the issue description, rather, this is the issue type description (for Task).

When you go down the response, there should be something like

  "issue": {
    "id": "10014",
    "key": "PZ-15",
    "fields": {
      "summary": "Test email notification",
      ...
     "description": ...
     ...
     }
...

Hope this helps.

Cheers,
Ian

@ianRagudo Thank you for the prompt response!

That field is also empty. Please see new attachments:

{
  "issue": {
    "id": "10014",
    "key": "PZ-15",
    "fields": {
      "summary": "Test email notification",
      "issuetype": {
        "self": "https://dan.atlassian.net/rest/api/2/issuetype/10001",
        "id": "10001",
        "description": "Tasks track small, distinct pieces of work.",
        "iconUrl": "https://dan.atlassian.net/rest/api/2/universal_avatar/view/type/issuetype/avatar/10318?size=medium",
        "name": "Task",
        "subtask": false,
        "avatarId": 10318,
        "entityId": "aa6d6f09-cacc-492a-af8e-4ae40ca3dbd2",
        "hierarchyLevel": 0
      },
      "creator": {
        "accountId": "5cb500f7ff4c750e404c6a5a"
      },
      "created": "2022-04-25T12:14:43.676-0700",
      "project": {
        "self": "https://dan.atlassian.net/rest/api/2/project/10000",
        "id": "10000",
        "key": "PZ",
        "name": "Project Zero",
        "projectTypeKey": "software",
        "simplified": true,
        "avatarUrls": {
          "48x48": "https://dan.atlassian.net/rest/api/2/universal_avatar/view/type/project/avatar/10419",
          "24x24": "https://dan.atlassian.net/rest/api/2/universal_avatar/view/type/project/avatar/10419?size=small",
          "16x16": "https://dan.atlassian.net/rest/api/2/universal_avatar/view/type/project/avatar/10419?size=xsmall",
          "32x32": "https://dan.atlassian.net/rest/api/2/universal_avatar/view/type/project/avatar/10419?size=medium"
        }
      },
      "reporter": {
        "accountId": "5cb500f7ff4c750e404c6a5a"
      },
      "assignee": null,
      "updated": "2022-04-26T19:45:09.362-0700",
      "status": {
        "self": "https://dan.atlassian.net/rest/api/2/status/10000",
        "description": "",
        "iconUrl": "https://dan.atlassian.net/",
        "name": "To Do",
        "id": "10000",
        "statusCategory": {
          "self": "https://dan.atlassian.net/rest/api/2/statuscategory/2",
          "id": 2,
          "key": "new",
          "colorName": "blue-gray",
          "name": "To Do"
        }
      }
    }
  },
  "atlassianId": "5cb500f7ff4c750e404c6a5a",
  "changelog": {
    "id": "10137",
    "items": [
      {
        "field": "status",
        "fieldtype": "jira",
        "fieldId": "status",
        "from": "10001",
        "fromString": "In Progress",
        "to": "10000",
        "toString": "To Do"
      }
    ]
  },
  "associatedUsers": [
    {
      "accountId": "5cb500f7ff4c750e404c6a5a"
    }
  ],
  "associatedStatuses": [
    {
      "self": "https://dan.atlassian.net/rest/api/2/status/10001",
      "description": "",
      "iconUrl": "https://dan.atlassian.net/",
      "name": "In Progress",
      "id": "10001",
      "statusCategory": {
        "self": "https://dan.atlassian.net/rest/api/2/statuscategory/4",
        "id": 4,
        "key": "indeterminate",
        "colorName": "yellow",
        "name": "In Progress"
      }
    },
    {
      "self": "https://dan.atlassian.net/rest/api/2/status/10000",
      "description": "",
      "iconUrl": "https://dan.atlassian.net/",
      "name": "To Do",
      "id": "10000",
      "statusCategory": {
        "self": "https://dan.atlassian.net/rest/api/2/statuscategory/2",
        "id": 2,
        "key": "new",
        "colorName": "blue-gray",
        "name": "To Do"
      }
    }
  ]
}

This is interesting, @DanLeeJo as the description field was not returned in the response body you posted (no description field inside fields in the response) :thinking: I tried both Version 2 and 3 of the Get issue REST API and in both cases it returned the description field.

Can you share your exact request? By any chance are you passing the fields query parameter and excluding description?

Also, can you try this in your browser https://dan.atlassian.net/rest/api/3/issue/PZ-15?fields=description which should return the description field.

Cheers,
Ian

Hi again @DJO . To avoid confusion, my previous comment was mainly for the REST API. For Forge Issue events, the description is not part of the fields based on the linked documentation.

Hi @ianRagudo let me share the full response from the REST API:
Response:

{
  expand: 'renderedFields,names,schema,operations,editmeta,changelog,versionedRepresentations,customfield_10010.requestTypePractice',
  id: '10014',
  self: 'https://api.atlassian.com/ex/jira/d538de98-70ff-46e3-90e7-366df849708a/rest/api/3/issue/10014',
  key: 'PZ-15',
  fields: {
    statuscategorychangedate: '2022-04-26T20:11:03.020-0700',
    issuetype: {
      self: 'https://api.atlassian.com/ex/jira/d538de98-70ff-46e3-90e7-366df849708a/rest/api/3/issuetype/10001',
      id: '10001',
      description: 'Tasks track small, distinct pieces of work.',
      iconUrl: 'https://api.atlassian.com/ex/jira/d538de98-70ff-46e3-90e7-366df849708a/rest/api/2/universal_avatar/view/type/issuetype/avatar/10318?size=medium',
      name: 'Task',
      subtask: false,
      avatarId: 10318,
      entityId: 'aa6d6f09-cacc-492a-af8e-4ae40ca3dbd2',
      hierarchyLevel: 0
    },
    timespent: null,
    customfield_10030: null,
    project: {
      self: 'https://api.atlassian.com/ex/jira/d538de98-70ff-46e3-90e7-366df849708a/rest/api/3/project/10000',
      id: '10000',
      key: 'PZ',
      name: 'Project Zero',
      projectTypeKey: 'software',
      simplified: true,
      avatarUrls: [Object]
    },
    fixVersions: [],
    aggregatetimespent: null,
    resolution: {
      self: 'https://api.atlassian.com/ex/jira/d538de98-70ff-46e3-90e7-366df849708a/rest/api/3/resolution/10000',
      id: '10000',
      description: 'Work has been completed on this issue.',
      name: 'Done'
    },
    customfield_10027: [],
    customfield_10028: null,
    customfield_10029: null,
    resolutiondate: '2022-04-26T20:11:03.010-0700',
    workratio: -1,
    lastViewed: null,
    watches: {
      self: 'https://api.atlassian.com/ex/jira/d538de98-70ff-46e3-90e7-366df849708a/rest/api/3/issue/PZ-15/watchers',
      watchCount: 1,
      isWatching: false
    },
    issuerestriction: { issuerestrictions: {}, shouldDisplay: true },
    created: '2022-04-25T12:14:43.676-0700',
    customfield_10020: null,
    customfield_10021: null,
    customfield_10022: null,
    customfield_10023: null,
    priority: {
      self: 'https://api.atlassian.com/ex/jira/d538de98-70ff-46e3-90e7-366df849708a/rest/api/3/priority/3',
      iconUrl: 'https://djo<hidden>.atlassian.net/images/icons/priorities/medium.svg',
      name: 'Medium',
      id: '3'
    },
    customfield_10024: null,
    customfield_10025: '10000_*:*_10_*:*_14712318_*|*_10002_*:*_6_*:*_1321669_*|*_10001_*:*_5_*:*_98945390',
    customfield_10026: null,
    labels: [],
    customfield_10016: null,
    customfield_10017: null,
    customfield_10018: {
      hasEpicLinkFieldDependency: false,
      showField: false,
      nonEditableReason: [Object]
    },
    customfield_10019: '0|i00033:',
    aggregatetimeoriginalestimate: null,
    timeestimate: null,
    versions: [],
    issuelinks: [],
    assignee: null,
    updated: '2022-04-26T20:11:03.020-0700',
    status: {
      self: 'https://api.atlassian.com/ex/jira/d538de98-70ff-46e3-90e7-366df849708a/rest/api/3/status/10002',
      description: '',
      iconUrl: 'https://api.atlassian.com/ex/jira/d538de98-70ff-46e3-90e7-366df849708a/',
      name: 'Done',
      id: '10002',
      statusCategory: [Object]
    },
    components: [],
    timeoriginalestimate: null,
    description: { version: 1, type: 'doc', content: [Array] },
    customfield_10010: null,
    customfield_10014: null,
    timetracking: {},
    customfield_10015: null,
    customfield_10005: null,
    customfield_10006: null,
    security: null,
    customfield_10007: null,
    customfield_10008: null,
    attachment: [],
    customfield_10009: null,
    aggregatetimeestimate: null,
    summary: 'Test email notification',
    creator: {
      self: 'https://api.atlassian.com/ex/jira/d538de98-70ff-46e3-90e7-366df849708a/rest/api/3/user?accountId=5cb500f7ff4c750e404c6a5a',
      accountId: '5cb500f7ff4c750e404c6a5a',
      avatarUrls: [Object],
      displayName: '<hidden>',
      active: true,
      timeZone: 'America/Los_Angeles',
      accountType: 'atlassian'
    },
    subtasks: [],
    reporter: {
      self: 'https://api.atlassian.com/ex/jira/d538de98-70ff-46e3-90e7-366df849708a/rest/api/3/user?accountId=5cb500f7ff4c750e404c6a5a',
      accountId: '5cb500f7ff4c750e404c6a5a',
      avatarUrls: [Object],
      displayName: '<hidden>',
      active: true,
      timeZone: 'America/Los_Angeles',
      accountType: 'atlassian'
    },
    customfield_10000: '{}',
    aggregateprogress: { progress: 0, total: 0 },
    customfield_10001: null,
    customfield_10002: null,
    customfield_10003: null,
    customfield_10004: null,
    environment: null,
    duedate: null,
    progress: { progress: 0, total: 0 },
    comment: {
      comments: [],
      self: 'https://api.atlassian.com/ex/jira/d538de98-70ff-46e3-90e7-366df849708a/rest/api/3/issue/10014/comment',
      maxResults: 0,
      total: 0,
      startAt: 0
    },
    votes: {
      self: 'https://api.atlassian.com/ex/jira/d538de98-70ff-46e3-90e7-366df849708a/rest/api/3/issue/PZ-15/votes',
      votes: 0,
      hasVoted: false
    },
    worklog: { startAt: 0, maxResults: 20, total: 0, worklogs: [] }
  }
}

I used this API by passing the event.issue.id from the trigger event:

export async function run(event, context) {
...
}

This is my function:

async function getIssueDetails(event) {
	const requestUrl = route`/rest/api/3/issue/${event.issue.id}`;
	let response = await api.asApp().requestJira(requestUrl, {
		method: "GET",
		headers: {
			'Accept': 'application/json'
		}
	});

	if (response.status !== 200) {
		console.log(response.status);
		throw `Unable to read issueId ${event.issue.id} Status: ${response.status}.`;
	}

	console.log(await response.json())

	return response.json();
}

I did not pass any parameters.

Odd, I do see the description from the URL you posted:

{"expand":"renderedFields,names,schema,operations,editmeta,changelog,versionedRepresentations","id":"10014","self":"https://dan.atlassian.net/rest/api/3/issue/10014","key":"PZ-15","fields":{"description":{"version":1,"type":"doc","content":[{"type":"paragraph","content":[{"type":"text","text":"This is the new description"}]}]}}}

Thanks, this clarifies things. From the quoted section above, the REST API returned the description but with the content not expanded (probably due to how it was logged). If you aren’t interested with a description in Atlassian Document Format (ADF), feel free to use the version 2 of the REST API (GET /rest/api/2/issue/{issueIdOrKey}) as it will be returned as a string.

Do let us know how it goes.

Cheers,
Ian

1 Like

V2 worked!

    components: [],
    timeoriginalestimate: null,
    description: 'This is the new description',
    customfield_10010: null,

Thank you so much for debugging this with me. I can work with this for now :slight_smile:

1 Like