google / google/flow-lens

Bad credentials error when using mode github_action

Open
#53 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
81
Forks
11
PR merge metrics
No merged PRs in 30d

Description

## Description
When using the GitHub action to generate a diagram in mode="github_action", I get the following error

```
Flow to UML is now running...
Failed to update GitHub comments: Error: Failed to fetch pull request review comments: Bad credentials - https://docs.github.com/rest
at GithubClient.getAllCommentsForPullRequest (https://jsr.io/@goog/flow-lens/0.1.12/src/main/github_client.ts:166:13)
at eventLoopTick (ext:core/01_core.js:178:7)
at async UmlWriter.writeGithubComment (https://jsr.io/@goog/flow-lens/0.1.12/src/main/uml_writer.ts:74:32)
at async UmlWriter.writeUmlDiagrams (https://jsr.io/@goog/flow-lens/0.1.12/src/main/uml_writer.ts:54:7)
error: Uncaught (in promise) Error: Failed to fetch pull request review comments: Bad credentials - https://docs.github.com/rest
throw new Error(
^
at GithubClient.getAllCommentsForPullRequest (https://jsr.io/@goog/flow-lens/0.1.12/src/main/github_client.ts:166:13)
at eventLoopTick (ext:core/01_core.js:178:7)
at async UmlWriter.writeGithubComment (https://jsr.io/@goog/flow-lens/0.1.12/src/main/uml_writer.ts:74:32)
at async UmlWriter.writeUmlDiagrams (https://jsr.io/@goog/flow-lens/0.1.12/src/main/uml_writer.ts:54:7)
Error: Process completed with exit code 1.
```

## Expected behavior

The authentication should pass and this error shouldn't appear.

## Additional details

The code for the Github action is the following, basically the one from the official example -

```
name: Pull Request Add Flow Lens

on:
pull_request:
branches:
- testing
- preprod
- main

jobs:
add_flow_lens:
name: Add Flow Lens to a PR that has added or changed flows
runs-on: [ raas-azure-shared ]
permissions: write-all
outputs:
changed_flows: ${{ steps.changed-files.outputs.flows_any_changed }}

steps:
- uses: actions/checkout@v3

# Collect all flow files that have been modified in this PR
- name: Get changed files of last push
id: changed-files
uses: tj-actions/changed-files@v46.0.1
with:
files_yaml: |
flows:
- force-app/main/default/flows/**


# Check if any flows files are changed, and print the result
- name: Print changes from previous step
id: print-changes
if: steps.changed-files.outputs.flows_any_changed == 'true'
env:
CHANGED_FLOW_FILES: ${{ steps.changed-files.outputs.flows_all_changed_files }}
run: |
echo "Number of changes flow(s): ${{ steps.changed-files.outputs.flows_all_changed_files_count }}"
for file in ${CHANGED_FLOW_FILES}; do
echo "$file was updated"
done

create_graph:
name: Add Flow Lens Graph if changed flows
needs: add_flow_lens
if: needs.add_flow_lens.outputs.changed_flows == 'true'
permissions: write-all
runs-on: [ raas-azure-shared ]
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.ref }}
fetch-depth: 2

# Install deno and cache installation package used by Flow Lens GitHub Action
- name: Install and cache deno
id: deno-install
uses: denoland/setup-deno@v2
with:
deno-version: latest
cache: true

# Generate flow diagrams
- name: Generate flow diagrams
run: |
deno run \
--allow-read \
--allow-write \
--allow-env \
--allow-net \
--allow-run \
jsr:@goog/flow-lens \
--mode="github_action" \
--diagramTool="mermaid" \
--gitDiffFromHash="HEAD^1" \
--gitDiffToHash="HEAD"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```

It is using a custom runner on an own company GitHub server. The runners can be Linux and Windows based, I get the same error with both.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.