Skip to content

No comment added to PR because "Problems parsing JSON" #113

@wjam

Description

@wjam

Describe the bug
I've just had a run --all plan run fail to add a comment to the PR. The response from GitHub appeared to be:

{
  "message": "Problems parsing JSON",
  "documentation_url": "https://docs.github.com/rest/issues/comments#create-an-issue-comment",
  "status": "400"
}

Looking at the code, I'd guess that this line is naive?

local -r escaped_message=$(printf '%s' "$message" | sed 's/\\/\\\\/g; s/"/\\"/g; s/$/\\n/g; s/\t/\\t/g' | tr -d '\n')

A better method is probably to get jq, which is already used a few lines earlier, to produce the JSON and pipe it into curl (like this: https://github.com/wjam/dotfiles/blob/6569ac73e6447611d8425f742d22e3d4b7900df2/home/private_dot_local/bin/executable_lights#L27-L28)?

To Reproduce

Difficult to reproduce - clearly something in the resulting log files managed to produce invalid JSON string, but it's difficult to say what without sharing the plan output (which is private).

Expected behavior

A comment should be added to the PR.

Nice to have

  • Terminal output
  • Screenshots

Versions

  • Terragrunt Action version: v2.1.8
  • Environment details (Terragrunt version, Terraform version, etc.): Terragrunt 0.83.2, Terraform 1.9.5

Additional context

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