-
Type:
Bug
-
Resolution: Tracked Elsewhere
-
Priority:
Low
-
2
-
Major
Issue Summary
Issues descriptions become corrupted when updating a description that contains an expand macro.
There does not appear to be any documentation of the format of expand macros for version 3 of the Jira REST API. The format of other macros are described at https://jira.atlassian.com/secure/WikiRendererHelpAction.jspa?section=all.
This is reproducible on Data Center: No
Steps to Reproduce
These steps are based on the following Typescript code:
const getIssueDescription = async (): Promise<string> => { const url = `${process.env.TENNANT_URL}/rest/api/2/issue/${process.env.ISSUE_KEY}?fields=description`; const response = await fetch(url, { headers: { 'Accept': 'application/json', 'Authorization': `Basic ${base64.encode(`${process.env.API_USERNAME}:${process.env.API_TOKEN}`)}` } }); const json = await response.json(); const description = json.fields.description; return description; } const setDescription = async (description): Promise<void> => { const url = `${process.env.TENNANT_URL}/rest/api/2/issue/${process.env.ISSUE_KEY}`; const payload = { fields: { "description": description } } await fetch(url, { method: 'PUT', headers: { 'Content-Type': 'application/json', 'Accept': 'application/json', 'Authorization': `Basic ${base64.encode(`${process.env.API_USERNAME}:${process.env.API_TOKEN}`)}` }, body: JSON.stringify(payload) }); } setTimeout(async () => { const description = await getIssueDescription(); console.log(`description = ${description}`); const newDescription = description; await setDescription(newDescription); });
The script uses environment variables as follows:
export TENNANT_URL=https://mytenant.atlassian.net
export API_USERNAME=foo@example.com
export API_TOKEN=bar
export ISSUE_KEY=TEST-11
Here is a tsconfig.json for the script:
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"lib": [
"es2015",
"es2015.promise",
"es2016",
"es6",
"esnext.asynciterable",
"DOM"
],
"outDir": "./dist",
"removeComments": true,
"noEmitOnError": true,
"skipLibCheck": true,
"strict": false,
"moduleResolution": "node",
"esModuleInterop": true,
"resolveJsonModule": true,
"downlevelIteration": true,
"types": [
"node"
]
},
"include": [
"src"
],
"exclude": [
"node_modules"
]
}
Here is the package.json:
{
"name": "jira-issue-expands-demo",
"version": "1.0.1",
"description": "",
"main": "index.js",
"type": "commonjs",
"engines": {
"node": ">=18.0.0"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "npx tsc && node dist/app.js"
},
"keywords": [],
"author": "",
"license": "MIT",
"dependencies": {
"base-64": "1.0.0"
},
"devDependencies": {
"@types/node": "^20.2.1",
"typescript": "^4.9.5"
}
}
To reproduce the issue:
- Step 1: Create an issue and update the description so it includes an expand macro.
- Step 2: Setup the above environment variable so the script can call the Jira REST API.
- Step 3: Run the script in Node 18 or later by executing `yarn start`.
Expected Results
The issue's description is unaffected.
Actual Results
The issue's description no longer has the expands.
Workaround
It is not feasible to use the ADF based V3 API because it is still in Beta.