I am trying to create issue comments through the v3 cloud API.
I am using the Atlassian Document Format builder NPM package (version 3.3.0).
Most comments seem to get posted just fine through an Axios rest call, however one type of comment seems to get rejected with the error "Comment body is not valid".
This is surprising since usually if your comment is invalid, the adf-builder library will throw the error before it gets to the rest call to POST the comment.
Does anyone have an idea as to what I might be doing wrong?
const doc = new Document();
if (this.isMerge) {
// clipped for brevity
} else {
doc
.panel("info")
.paragraph()
.strong(`PR Created by ${this.props.author} `)
.hardBreak()
.hardBreak()
.link(`View Pull Request`, this.props.url)
.hardBreak()
.hardBreak()
.text(this.props.title)
.hardBreak()
.hardBreak()
.strong("Source Branch: ")
.text(`${this.props.source}`)
.hardBreak()
.strong("Target Branch: ")
.text(` ${this.props.target}`);
}
return doc.toJSON();
And here is the output
{
"body":{
"type":"doc",
"content":[
{
"type":"panel",
"content":[
{
"type":"paragraph",
"content":[
{
"type":"text",
"text":"PR Created by Taylor Ackley ",
"marks":[
{
"type":"strong"
}
]
},
{
"type":"hardBreak",
"attrs":{
"text":"\\n"
}
},
{
"type":"hardBreak",
"attrs":{
"text":"\\n"
}
},
{
"type":"text",
"text":"View Pull Request",
"marks":[
{
"type":"link",
"attrs":{
"href":"some branch"
}
}
]
},
{
"type":"hardBreak",
"attrs":{
"text":"\\n"
}
},
{
"type":"hardBreak",
"attrs":{
"text":"\\n"
}
},
{
"type":"text",
"text":"some ticket"
},
{
"type":"hardBreak",
"attrs":{
"text":"\\n"
}
},
{
"type":"hardBreak",
"attrs":{
"text":"\\n"
}
},
{
"type":"text",
"text":"Source Branch: ",
"marks":[
{
"type":"strong"
}
]
},
{
"type":"text",
"text":"users/taylor/xxxx-xxx"
},
{
"type":"hardBreak",
"attrs":{
"text":"\\n"
}
},
{
"type":"text",
"text":"Target Branch: ",
"marks":[
{
"type":"strong"
}
]
},
{
"type":"text",
"text":" support-20190702"
}
]
}
],
"attrs":{
"panelType":"success"
}
}
],
"version":1
}
}
IT seems as if it has something to do with the hard breaks. If I zap all the hard breaks, it seems to go through.
However, I have a similar function that generates a comment that is very similar and works.
working
const doc = new Document();
doc
.panel("success")
.paragraph()
.strong(`Deployment on ${this.props.env} Succeeded `).emoji(':rocket:')
.hardBreak()
.hardBreak()
.link("Release Summary", this.props.summary);
doc.paragraph().strong("Commits");
const list = doc.bulletList();
for (let c of ticket.commits) {
list
.item()
.paragraph()
.link(c.message, c.link)
.text(` (${c.author})`);
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.