We've been using infracost successfully in GitHub ...
# general
h
We've been using infracost successfully in GitHub Actions for a long time, but just recently our
infracost comment github ...
commands started failing with
The pull request comment was generated successfully but could not be posted:\njson: cannot unmarshal number 2147719327 into Go value of type <http://githubv4.Int|githubv4.Int>
. Can anybody suggest how to troubleshoot this? I'll post our usage in a thread.
Our complete GitHub Action:
Copy code
# <https://github.com/infracost/actions/#quick-start>
name: Infracost

on:
  pull_request:
    paths:
      - 'terraform/environments/production/**.tf'
      - 'terraform/modules/aws/application/**.tf'

jobs:
  infracost:
    name: Infracost
    runs-on: ubuntu-latest
    permissions:
      contents: read
      pull-requests: write

    env:
      TF_ROOT: terraform/environments/production

    steps:
      - name: Setup Infracost
        uses: infracost/actions/setup@v3
        # See <https://github.com/infracost/actions/tree/master/setup> for other inputs
        with:
          api-key: ${{ secrets.INFRACOST_API_KEY }}

      # Checkout the base branch of the pull request (e.g. main/master).
      - name: Checkout base branch
        uses: actions/checkout@v4
        with:
          ref: '${{ github.event.pull_request.base.ref }}'

      # Generate Infracost JSON file as the baseline.
      - name: Generate Infracost cost estimate baseline
        run: |
          infracost breakdown --path=${TF_ROOT} \
                              --project-name production \
                              --format=json \
                              --out-file=/tmp/infracost-base.json
        env:
          INFRACOST_API_KEY: ${{ secrets.INFRACOST_API_KEY }}

      # Checkout the current PR branch so we can create a diff.
      - name: Checkout PR branch
        uses: actions/checkout@v4

      # Generate an Infracost diff and save it to a JSON file.
      - name: Generate Infracost diff
        run: |
          infracost diff --path=${TF_ROOT} \
                          --project-name production \
                          --format=json \
                          --compare-to=/tmp/infracost-base.json \
                          --out-file=/tmp/infracost.json
        env:
          INFRACOST_API_KEY: ${{ secrets.INFRACOST_API_KEY }}

      # Posts a comment to the PR using the 'update' behavior.
      # This creates a single comment and updates it. The "quietest" option.
      # The other valid behaviors are:
      #   update (default)  Update latest comment
      #   delete-and-new - Delete previous comments and create a new one.
      #   hide-and-new - Minimize previous comments and create a new one.
      #   new - Create a new cost estimate comment on every push.
      # See <https://www.infracost.io/docs/features/cli_commands/#comment-on-pull-requests> for other options.
      - name: Post Infracost comment
        run: |
            infracost comment github --path=/tmp/infracost.json \
                                     --repo=$GITHUB_REPOSITORY \
                                     --github-token=${{github.token}} \
                                     --pull-request=${{github.event.pull_request.number}} \
                                     --behavior=update
        env:
          INFRACOST_API_KEY: ${{ secrets.INFRACOST_API_KEY }}
here is the output of debug mode:
Copy code
2024-06-04T15:02:21Z DEBUG IsCloudEnabled inferred from Config.EnabledDashboard is_cloud_enabled=false
2024-06-04T15:02:21Z INFO Finding matching comments for tag infracost-comment
2024-06-04T15:02:22Z DEBUG received an error trying to post comment pausing 1 seconds then will retry error="The pull request comment was generated successfully but could not be posted:\njson: cannot unmarshal number 2147719327 into Go value of type <http://githubv4.Int|githubv4.Int>\n\nSee <https://infracost.io/docs/troubleshooting/#5-posting-comments> for help."
2024-06-04T15:02:23Z INFO Finding matching comments for tag infracost-comment
2024-06-04T15:02:23Z DEBUG received an error trying to post comment pausing 2 seconds then will retry error="The pull request comment was generated successfully but could not be posted:\njson: cannot unmarshal number 2147719327 into Go value of type <http://githubv4.Int|githubv4.Int>\n\nSee <https://infracost.io/docs/troubleshooting/#5-posting-comments> for help."
2024-06-04T15:02:25Z INFO Finding matching comments for tag infracost-comment
2024-06-04T15:02:25Z DEBUG received an error trying to post comment pausing 4 seconds then will retry error="The pull request comment was generated successfully but could not be posted:\njson: cannot unmarshal number 2147719327 into Go value of type <http://githubv4.Int|githubv4.Int>\n\nSee <https://infracost.io/docs/troubleshooting/#5-posting-comments> for help."
2024-06-04T15:02:29Z INFO Finding matching comments for tag infracost-comment
2024-06-04T15:02:29Z DEBUG received an error trying to post comment pausing 8 seconds then will retry error="The pull request comment was generated successfully but could not be posted:\njson: cannot unmarshal number 2147719327 into Go value of type <http://githubv4.Int|githubv4.Int>\n\nSee <https://infracost.io/docs/troubleshooting/#5-posting-comments> for help."
2024-06-04T15:02:37Z INFO Finding matching comments for tag infracost-comment
Error: The pull request comment was generated successfully but could not be posted:
json: cannot unmarshal number 2147719327 into Go value of type <http://githubv4.Int|githubv4.Int>
See <https://infracost.io/docs/troubleshooting/#5-posting-comments> for help.
2024-06-04T15:02:37Z DEBUG 'POST' request to '/event' using trace_id: 'b0d328f3-3402-4aad-a9b5-f52f7b824171'
2024-06-04T15:02:37Z DEBUG performing request method POST url <https://pricing.api.infracost.io/event> library=retryablehttp
Error: Process completed with exit code 1.
##[debug]Finishing: Post Infracost comment
c
Hi thanks for reporting. We are working on pushing a release for this now.
There is an issue in our github graphql client where we were are not handling int64s correctly.
h
thanks for the quick reply, and for addressing the underlying issue. am i correct in assuming that once the fix is pushed, then
uses: infracost/actions/setup@v3
will pick up the newly released version and our action will just work again?
c
yes
h
perfect. thank you.