Cannot get Forge Attachment Count Custom Field example to work

I am trying to run this example:
https://bitbucket.org/atlassian/forge-attachment-count-custom-field/src/master/

When I run the web trigger with this command:

curl -X POST <url> -H "Content-Type: application/json" -d '{"startAt":0, "maxResults": 1000}'

I get the following error:

{"timestamp":"2024-09-19T14:07:48.478+00:00","path":"/x1/_kbc2N2bDYqdgxkcLB470IVc7EY","status":424,"error":"Failed Dependency","requestId":"24796d3c-858976"

and in the tunnel, I get the following:

INFO    16:07:14.426  ab72e692-8a7f-4da5-8564-81bc8f1b885f  REQUEST: POST [object Object] {"expression":"issues.reduce((acc, i) => acc.set(i.attachments.length+'', (acc[i.attachments.length+''] || []).concat(i.id)), {})","context":{"issues":{"jql":{"query":"order by id","startAt":0,"maxResults":1000}}}}
ERROR   16:07:14.904  ab72e692-8a7f-4da5-8564-81bc8f1b885f  FetchError: invalid json response body at https://jira/rest/api/2/expression/eval reason: Unexpected end of JSON input
    at <anonymous> (webpack://jira-custom-field-ui-kit-2/node_modules/node-fetch/lib/index.mjs:267:1)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Object.setUpAttachmentCount (webpack://jira-custom-field-ui-kit-2/src/attachments.js:20:1)
    at async /tmp/tunnel-563429-mfUk0COR6kbp/attachments.cjs:2:511617
    at async process.<anonymous> (/home/anders/.nvm/versions/node/v20.17.0/lib/node_modules/@forge/cli/node_modules/@forge/tunnel/out/sandbox/sandbox-runner.js:7:20) {
  type: 'invalid-json'
}

Does anyone have an idea to what I am doing wrong?

Thanks in advance :slight_smile:

Having the same issue when I tried the following tutorial
https://developer.atlassian.com/platform/forge/automate-bitbucket-using-triggers/

ERROR   16:13:19.240  xxxxx-xxxx-xxxxxx  FetchError: invalid json response body at https://forge-outbound-proxy.services.atlassian.com/fpp/provider/app/remote/bitbucket reason: Unexpected token 'P', "Proxy Auth"... is not valid JSON
    at <anonymous> (webpack://product-trigger/node_modules/node-fetch/lib/index.mjs:267:1)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at addComment (webpack://product-trigger/src/index.jsx:22:1)
    at Object.run (webpack://product-trigger/src/index.jsx:28:1)
    at async /private/var/folders/_6/811c1kx57tj6lmr_cw3l9lm40000gn/T/tunnel-87660-MRcn3EnYPj7h/index.cjs:2:511617
    at async process.<anonymous> (/usr/local/lib/node_modules/@forge/cli/node_modules/@forge/tunnel/out/sandbox/sandbox-runner.js:7:20) {
  type: 'invalid-json'
}

Hi KelpMine!

Welcome to for Forge developer community.

Since the example you were looking at works with attachments, your app might have run into an egress permission issue for the URL associated with attachments. Per the Forge changelog, Forge was updated in October so that apps now automatically have egress permission to the attachments URL.

Try this:

  1. Pick up the latest version of the Forge CLI with npm install -g @forge/cli@latest
  2. Get the latest Forge API package, from your app’s root folder, with npm install @forge/api@latest

If your manifest still uses the old sandbox runtime, you may also need to update the app entry in it to the latest runtime, as follows:

app:
  runtime:
    name: nodejs18.x
  id: your-app-id-here

Let us know if this helps.