Atlassian CLI – Using a heading in Atlassian Document Format to create a comment returns an error

While trying to add a comment with a heading node on a work item using the CLI, I receive the following error:

Can't be edited: io.atlassian.micros.clibackend.exceptions.InvalidPayloadException: INVALID_INPUT, INVALID_INPUT.

It works fine when I use a paragraph node instead.

I’m using the documentation here to create the payload:
https://developer.atlassian.com/cloud/jira/platform/apis/document/nodes/heading/

Does anyone know what I might be doing wrong?

{
  "version": 1,
  "type": "doc",
  "content": [
    {
        "type": "heading",
        "attrs": {
          "level": 1
        },
        "content": [
          {
            "type": "text",
            "text": "Heading 1"
          }
        ]
      }
  ]
}


1 Like

Hello @CedrickPlante

Firstly, when you say “Command Line Interface (CLI)”, do you just mean Jira’s REST API?

  1. The ADF sample you have provided doesn’t use a paragraph node, only a heading node, so it’s not clear what you mean by that.
  2. There’s no ‘comment’ anywhere in that ADF, so it’s not clear what you mean by that.
  3. You’ve tagged your question as related to Atlassian Development Tools, but haven’t said which one you’re using or what language, libraries or functions are being using.
  4. You haven’t provided a reproducible code sample of the actual request that shows:
    1. which specific API endpoint is being used,
    2. which method is being used,
    3. what authentication type is being used.

Perhaps refer to the How to ask a good question thread to better understand the minimum level of information that’s expected for someone to be able to assist you.

In the interim, use the Document builder and Document viewer online tools to test and validate any ADF you create.

PS. If you use the Document viewer tool with the ADF sample you have provided, you will see that the ADF is perfectly valid!

@sunnyape Hi Sunnyape,

Apologies if my previous message was unclear. Here’s some additional context:

I’m developing an agent that leverages the Atlassian Command Line Interface (CLI) to retrieve and add comments to Jira work items.

Initially, the agent executes the following command:
acli jira workitem view {key} --json --fields "description,summary,comment"

It then analyzes the associated code to plan the required work.

Finally, the agent adds a comment to the work item outlining the steps necessary to complete the task by running the following command:
acli jira workitem comment --key "{key}" --body-file "tmp.json"

I used an API token with full permissions to authenticate the CLI.

I used the Atlassian Document Format Playground to build the content for tmp.json.

When tmp.json contains the following:

{
  "version": 1,
  "type": "doc",
  "content": [
    {
      "type": "paragraph",
      "content": [
        {
          "type": "text",
          "text": "Test"
        }
      ]
    }
  ]
}

Everything works correctly — the comment is created.

However, when tmp.json contains:

{
  "version": 1,
  "type": "doc",
  "content": [
    {
      "type": "heading",
      "attrs": {
        "level": 1
      },
      "content": [
        {
          "type": "text",
          "text": "TEST"
        }
      ]
    }
  ]
}

The command fails and returns the following error:

can't be edited: io.atlassian.micros.clibackend.exceptions.InvalidPayloadException: INVALID_INPUT, INVALID_INPUT

I hope this explanation provides more clarity.

2 Likes

Thanks for the detailed explanation, that’s perfect and I understand exactly what you’re referring to.

Firstly, there’s a mistake with the comment command as you’ve cited it, as you’ve omitted the create part of the command. The CLI command would be:

acli jira workitem comment create --key "{key}" --body-file "tmp.json"

Also, there might be a mistake in the documentation for the Jira Comment Create command, as it says:

Options

--body-file string. Plain text file with text or Atlassian Document Format (ADF)

but you might have to specify the comment’s format as ADF using the --body option, not the --body-file option, the same as for the Jira Comment Update command. When I use the --help flag with jira workitem comment create command, the response matches the documentation and says the body file can be text OR ADF, so that’s a longshot that it’s a documentation mistake.

It’s strange that the Jira Comment Update command says:

Options

–body-file string. Plain text file containing comment body

so, it says nothing about being able to use an ADF formatted text file when updating a comment. It’s even stranger that, when updating an existing comment using ADF, you have to use a --body-adf option to ‘pre-warn’ the command what type of text string is being supplied, whereas that’s not required when creating a new comment.

You may have found a fault with the CLI’s ADF parser for the heading node, so have a go at formatting the tmp.json file as plain text using wiki markup and see if that works with the --body-file option. The plain text wiki markdown for a L1 heading would simply be:

#Test

Wiki markdown is often much easier to encode than ADF for simpler text entries.

Lastly, try declaring the wiki text and JSON encoded ADF version of the comment body directly into the jira workitem comment create command as a --body string and bypass using the intermediate text file. That might isolate the problem to being the mechanism that parses the file, not the actual ADF itself.

1 Like