rematocorp / trello-integration-action

GitHub action for connecting GitHub PRs and Trello cards — moves cards, adds labels & people, and more
MIT License
18 stars 11 forks source link

/new-trello-card fails to obtain the url in the response. #96

Closed alanfzf closed 5 months ago

alanfzf commented 5 months ago

When the /new-trello-card command is used, the card gets moved in the trello board, but when trying to obtain the url it just fails.

image

ukupat commented 5 months ago

Thanks for reporting! Very interesting case, especially because you say the card is created. Are you able to reproduce this error consistently? Also, is the rest of the integration functioning as intended?

Please also double-check if your Trello list ID, API key and token are correct 🤔

ukupat commented 5 months ago

I also released v9.2.3 with better error logging, you can try to upgrade so we could get more context :)

ukupat commented 5 months ago

@alanfzf any updates?

alanfzf commented 5 months ago

Hello @ukupat , thanks for your response, i been a bit busy this week, but i hopefully will get back to you with a more documented issue, this weekend.

alanfzf commented 5 months ago

Hello @ukupat bumped to v9.2.3 image

and it seems that it can't find the board where the card belongs to, also i wasn't able to reproduce the card creation, bug.

I double checked, and it seems that api credentials were ok, as the cards get created when i manually put the trello url.

Im going to share what bits of the json im using to associate the trello board:

trello-board-id: 6621c337327b56c3ac6acbbc
trello-list-id-pr-open: 6621c337327b56c3ac6acbc3
trello-list-id-pr-closed: 6621c337327b56c3ac6acbc5

image

First list ```json { "id": "6621d558b221f62178944ebf", "address": null, "badges": { "attachmentsByType": { "trello": { "board": 0, "card": 0 } }, "location": false, "votes": 0, "viewingMemberVoted": false, "subscribed": false, "fogbugz": "", "checkItems": 0, "checkItemsChecked": 0, "checkItemsEarliestDue": null, "comments": 0, "attachments": 0, "description": false, "due": null, "dueComplete": false, "start": null }, "checkItemStates": [], "closed": false, "coordinates": null, "creationMethod": null, "dueComplete": false, "dateLastActivity": "2024-04-19T02:22:16.390Z", "desc": "", "descData": { "emoji": {} }, "due": null, "dueReminder": null, "email": "alanfzf+2rpbst4exu5pxptztgt+32bkhmxlqgk8bn39txb+2fr6djqs2s@boards.trello.com", "idBoard": "6621c337327b56c3ac6acbbc", "idChecklists": [], "idLabels": [], "idList": "6621c337327b56c3ac6acbc3", "idMembers": [], "idMembersVoted": [], "idOrganization": "611f6e73aaffc882ef5a9648", "idShort": 7, "idAttachmentCover": null, "labels": [], "limits": { "attachments": { "perCard": { "status": "ok", "disableAt": 1000, "warnAt": 800 } }, "checklists": { "perCard": { "status": "ok", "disableAt": 500, "warnAt": 400 } }, "stickers": { "perCard": { "status": "ok", "disableAt": 70, "warnAt": 56 } } }, "locationName": null, "manualCoverAttachment": false, "name": ":building_construction: (refactor): djksak", "nodeId": "ari:cloud:trello::card/workspace/611f6e73aaffc882ef5a9648/6621d558b221f62178944ebf", "pos": 8192, "shortLink": "hcdzYUZD", "shortUrl": "https://trello.com/c/hcdzYUZD", "staticMapUrl": null, "start": null, "subscribed": false, "url": "https://trello.com/c/hcdzYUZD/7-buildingconstruction-refactor-djksak", "cover": { "idAttachment": null, "color": null, "idUploadedBackground": null, "size": "normal", "brightness": "dark", "idPlugin": null }, "isTemplate": false, "cardRole": null, "checklists": [], "customFieldItems": [], "members": [], "pluginData": [], "actions": [ { "id": "6621d558b221f62178944eca", "idMemberCreator": "5c4d715875c62687537d10ed", "data": { "card": { "id": "6621d558b221f62178944ebf", "name": ":building_construction: (refactor): djksak", "idShort": 7, "shortLink": "hcdzYUZD" }, "list": { "id": "6621c337327b56c3ac6acbc3", "name": "To Do" }, "board": { "id": "6621c337327b56c3ac6acbbc", "name": "TestBoard", "shortLink": "BLNpNrGK" } }, "appCreator": { "id": "6621c31143521a205892a78d" }, "type": "createCard", "date": "2024-04-19T02:22:16.408Z", "limits": null, "memberCreator": { "id": "5c4d715875c62687537d10ed", "activityBlocked": false, "avatarHash": "10c9d1754119c33bb20a8e2aec9f964f", "avatarUrl": "https://trello-members.s3.amazonaws.com/5c4d715875c62687537d10ed/10c9d1754119c33bb20a8e2aec9f964f", "fullName": "Alan David", "idMemberReferrer": null, "initials": "AD", "nonPublic": { "fullName": "Alan David", "initials": "AD", "avatarUrl": "https://trello-members.s3.amazonaws.com/5c4d715875c62687537d10ed/10c9d1754119c33bb20a8e2aec9f964f", "avatarHash": "10c9d1754119c33bb20a8e2aec9f964f" }, "nonPublicAvailable": true, "username": "alanfzf" } } ] } ```
Second list ```json { "id": "662e0a1baa184cfbbb3ec066", "address": null, "badges": { "attachmentsByType": { "trello": { "board": 0, "card": 0 } }, "location": false, "votes": 0, "viewingMemberVoted": false, "subscribed": false, "fogbugz": "", "checkItems": 0, "checkItemsChecked": 0, "checkItemsEarliestDue": null, "comments": 0, "attachments": 0, "description": false, "due": null, "dueComplete": false, "start": null }, "checkItemStates": [], "closed": false, "coordinates": null, "creationMethod": null, "dueComplete": false, "dateLastActivity": "2024-04-28T08:34:35.523Z", "desc": "", "descData": { "emoji": {} }, "due": null, "dueReminder": null, "email": "alanfzf+2rpbst4exu5pxptztgt+32df8ki2xup7jxj81gm+2egk59shdm@boards.trello.com", "idBoard": "6621c337327b56c3ac6acbbc", "idChecklists": [], "idLabels": [], "idList": "6621c337327b56c3ac6acbc5", "idMembers": [], "idMembersVoted": [], "idOrganization": "611f6e73aaffc882ef5a9648", "idShort": 8, "idAttachmentCover": null, "labels": [], "limits": { "attachments": { "perCard": { "status": "ok", "disableAt": 1000, "warnAt": 800 } }, "checklists": { "perCard": { "status": "ok", "disableAt": 500, "warnAt": 400 } }, "stickers": { "perCard": { "status": "ok", "disableAt": 70, "warnAt": 56 } } }, "locationName": null, "manualCoverAttachment": false, "name": "dsa", "nodeId": "ari:cloud:trello::card/workspace/611f6e73aaffc882ef5a9648/662e0a1baa184cfbbb3ec066", "pos": 65536, "shortLink": "5X26QFsh", "shortUrl": "https://trello.com/c/5X26QFsh", "staticMapUrl": null, "start": null, "subscribed": false, "url": "https://trello.com/c/5X26QFsh/8-dsa", "cover": { "idAttachment": null, "color": null, "idUploadedBackground": null, "size": "normal", "brightness": "dark", "idPlugin": null }, "isTemplate": false, "cardRole": null, "checklists": [], "customFieldItems": [], "members": [], "pluginData": [], "actions": [ { "id": "662e0a1baa184cfbbb3ec06f", "idMemberCreator": "5c4d715875c62687537d10ed", "data": { "card": { "id": "662e0a1baa184cfbbb3ec066", "name": "dsa", "idShort": 8, "shortLink": "5X26QFsh" }, "list": { "id": "6621c337327b56c3ac6acbc5", "name": "FINALIZADO" }, "board": { "id": "6621c337327b56c3ac6acbbc", "name": "TestBoard", "shortLink": "BLNpNrGK" } }, "appCreator": null, "type": "createCard", "date": "2024-04-28T08:34:35.538Z", "limits": null, "memberCreator": { "id": "5c4d715875c62687537d10ed", "activityBlocked": false, "avatarHash": "10c9d1754119c33bb20a8e2aec9f964f", "avatarUrl": "https://trello-members.s3.amazonaws.com/5c4d715875c62687537d10ed/10c9d1754119c33bb20a8e2aec9f964f", "fullName": "Alan David", "idMemberReferrer": null, "initials": "AD", "nonPublic": { "fullName": "Alan David", "initials": "AD", "avatarUrl": "https://trello-members.s3.amazonaws.com/5c4d715875c62687537d10ed/10c9d1754119c33bb20a8e2aec9f964f", "avatarHash": "10c9d1754119c33bb20a8e2aec9f964f" }, "nonPublicAvailable": true, "username": "alanfzf" } } ] } ```
alanfzf commented 5 months ago

Oops, seems like the first action was sent with an incorrect idList updated it and get this new error:

image

and was able to reproduce the issue, the card gets created, but fails to return the url:

image

image

Sharing the new log with all the details:

Log ```bash Searching for card ids Creating card based on PR info teskajdsj Updating PR body https://trello.com/c/Gc5HHONS/10-teskajdsj Error: HttpError: Resource not accessible by integration /home/runner/work/_actions/rematocorp/trello-integration-action/v9.2.3/dist/index.js:6902 const error = new import_request_error.RequestError(toErrorMessage(data), status, { ^ RequestError [HttpError]: Resource not accessible by integration at /home/runner/work/_actions/rematocorp/trello-integration-action/v9.2.3/dist/index.js:6902:21 at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async updatePullRequestBody (/home/runner/work/_actions/rematocorp/trello-integration-action/v9.2.3/dist/index.js:34147:5) at async createNewCard (/home/runner/work/_actions/rematocorp/trello-integration-action/v9.2.3/dist/index.js:34374:9) at async getCardIds (/home/runner/work/_actions/rematocorp/trello-integration-action/v9.2.3/dist/index.js:34343:27) at async run (/home/runner/work/_actions/rematocorp/trello-integration-action/v9.2.3/dist/index.js:34722:25) { status: 403, response: { url: 'https://api.github.com/repos/alanfzf/test-trello-ci/issues/16', status: 403, headers: { 'access-control-allow-origin': '*', 'access-control-expose-headers': 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset', 'content-encoding': 'gzip', 'content-security-policy': "default-src 'none'", 'content-type': 'application/json; charset=utf-8', date: 'Sun, 28 Apr [20](https://github.com/alanfzf/test-trello-ci/actions/runs/8866382228/job/24343759688#step:2:21)24 08:43:12 GMT', 'referrer-policy': 'origin-when-cross-origin, strict-origin-when-cross-origin', server: 'GitHub.com', 'strict-transport-security': 'max-age=31536000; includeSubdomains; preload', 'transfer-encoding': 'chunked', vary: 'Accept-Encoding, Accept, X-Requested-With', 'x-accepted-github-permissions': 'issues=write; pull_requests=write', 'x-content-type-options': 'nosniff', 'x-frame-options': 'deny', 'x-github-api-version-selected': '2022-11-28', 'x-github-media-type': 'github.v3; format=json', 'x-github-request-id': 'D081:11592F:75D9CC7:B6E8F77:662E0C1F', 'x-ratelimit-limit': '5000', 'x-ratelimit-remaining': '4992', 'x-ratelimit-reset': '1714296298', 'x-ratelimit-resource': 'core', 'x-ratelimit-used': '8', 'x-xss-protection': '0' }, data: { message: 'Resource not accessible by integration', documentation_url: 'https://docs.github.com/rest/issues/issues#update-an-issue' } }, request: { method: 'PATCH', url: 'https://api.github.com/repos/alanfzf/test-trello-ci/issues/16', headers: { accept: 'application/vnd.github.v3+json', 'user-agent': 'octokit-core.js/5.0.1 Node.js/20.8.1 (linux; x64)', authorization: 'token [REDACTED]', 'content-type': 'application/json; charset=utf-8' }, body: '{"body":"https://trello.com/c/Gc5HHONS/10-teskajdsj"}', request: { agent: Agent { _events: [Object: null prototype] { free: [Function (anonymous)], newListener: [Function: maybeEnableKeylog] }, _eventsCount: 2, _maxListeners: undefined, defaultPort: 443, protocol: 'https:', options: [Object: null prototype] { keepAlive: true, scheduling: 'lifo', timeout: 5000, noDelay: true, path: null }, requests: [Object: null prototype] {}, sockets: [Object: null prototype] {}, freeSockets: [Object: null prototype] { 'api.trello.com:443:::::::::::::::::::::': [ [TLSSocket] ] }, keepAliveMsecs: 1000, keepAlive: true, maxSockets: Infinity, maxFreeSockets: [25](https://github.com/alanfzf/test-trello-ci/actions/runs/8866382228/job/24343759688#step:2:26)6, scheduling: 'lifo', maxTotalSockets: Infinity, totalSocketCount: 1, maxCachedSessions: 100, _sessionCache: { map: { 'api.trello.com:443:::::::::::::::::::::': [Buffer [Uint8Array]] }, list: [ 'api.trello.com:443:::::::::::::::::::::' ] }, [Symbol(kCapture)]: false }, fetch: [Function: proxyFetch], hook: [Function: bound bound register] } } } Node.js v20.8.1 ```
alanfzf commented 5 months ago

From what i can understand the issue, is occuring when the action, tries to update the body of the pull request, afaik, my action.yaml is configured correctly but here it is anyway:

name: Trello integration
on:
    pull_request:
        types: [opened, edited, closed, reopened, ready_for_review, converted_to_draft]
    issue_comment:
        types: [created, edited]
jobs:
    trello:
        runs-on: ubuntu-latest
        environment: Test
        steps:
            - uses: rematocorp/trello-integration-action@v9.2.3
              with:
                  github-token: ${{ secrets.GITHUB_TOKEN }}
                  github-include-new-card-command: true
                  trello-api-key: ${{ secrets.TRELLO_API_KEY }}
                  trello-auth-token: ${{ secrets.TRELLO_AUTH_TOKEN }}
                  trello-board-id: 6621c337327b56c3ac6acbbc
                  trello-list-id-pr-open: 6621c337327b56c3ac6acbc3
                  trello-list-id-pr-closed: 6621c337327b56c3ac6acbc5

edit: solved it, you actually need to give write permissions in the action file for it to work.

name: Trello integration
on:
    pull_request:
        types: [opened, edited, closed, reopened, ready_for_review, converted_to_draft]
    issue_comment:
        types: [created, edited]
jobs:
    trello:
        runs-on: ubuntu-latest
        permissions:
          pull-requests: write
        environment: Test
        steps:
            - uses: rematocorp/trello-integration-action@v9.2.3
              with:
                  github-token: ${{ secrets.GITHUB_TOKEN }}
                  github-include-new-card-command: true
                  trello-api-key: ${{ secrets.TRELLO_API_KEY }}
                  trello-auth-token: ${{ secrets.TRELLO_AUTH_TOKEN }}
                  trello-board-id: 6621c337327b56c3ac6acbbc
                  trello-list-id-pr-open: 6621c337327b56c3ac6acbc3
                  trello-list-id-pr-closed: 6621c337327b56c3ac6acbc5
alanfzf commented 5 months ago

Made small pr to add this info in the main readme file! 😄 thanks, for your time @ukupat !

ukupat commented 5 months ago

Hmm interesting find. We use a custom token for github-token with more permissions so I guess thats why we didn't encounter this problem. Thank you for the information and for the PR!