microsoft / AL-Go

The plug-and-play DevOps solution for Business Central app development on GitHub
MIT License
293 stars 125 forks source link

[Bug]: appDependencyProbingPaths authentication error when using localdevenv #1206

Closed frottke closed 3 weeks ago

frottke commented 2 months ago

AL-Go version

5.3

Describe the issue

When downloading the dependencies via "appDependencyProbingPaths" in CI/CD it works like it should but via localdevenv.ps1 it says -> "Error: Response status code does not indicate success: 404 (Not Found)."

The same configuration is applied.

relevant log ->

Checking appDependencyProbingPaths
Dependency to projects '*' in https://github.com/foo/bar@branch1, version latest, release status latestBuild
Using secret CustomSecret for access to repository
Downloading dependencies ...
Locating Apps artifacts for projects: *
Finding latest successful CICD run for branch branch1 in repository foo/bar
- https://api.github.com/repos/foo/bar/actions/runs?per_page=100&page=1&exclude_pull_requests=true&status=completed&branch=branch1
Response status code does not indicate success: 404 (Not Found). 

We already checked if there a artifacts available by simply running CI/CD. That way it works, same config

Expected behavior

correct download of the artifacts

Steps to reproduce

config an appDependencyProbingPaths with an external private repository out of the own organisation

Additional context (logs, screenshots, etc.)

No response

KristofKlein commented 1 month ago

Just an idea: A 404 in that case could also indicate that you do not have enough rights for the operation against gh. is this using the gh cli command ? if so, you can check what rights you have. gh cli has its own token (gho_). run

gh auth status on the local machine. you normally only get a really limited Token scope. However you can extend this scopes with --scopes : gh auth refresh --scopes read:packages

if this is not making use of the gh cli and runs the command straight against the API, you might want to check your created token (ghg_)

compare to this: https://github.com/microsoft/AL-Go/discussions/1141#discussioncomment-10084671

frottke commented 1 month ago

it looks like the PAT is used but has an different behaviour in the workflow compared to the local dev script. giving myself more permissions via gh auth refresh is no solution because the repository I want to access via the PAT is outside of my own organisation.

frottke commented 1 month ago

@freddydk would you be so kind and have a look at this issue? This issue is currently hampers our productivity when creating local containers.

freddydk commented 1 month ago

When using localdevenv - it should use your current GitHub access token to download the dependencies. Can you confirm that you have access to these repos and the built apps?

frottke commented 1 month ago

we do not have access to the external repository but within appDependencyProbingPaths is an defined AuthTokenSecret which works in the workflow, but not in localdevenv. It looks like if the token is "not applied".

freddydk commented 1 month ago

GitHub secrets cannot be extracted locally - this when running localdevenv, you need access to at least read from these repositories - or use GitHubPackagesContext (NuGet) to share dependencies between repositories.