ruff-action: Error: not found when using action on self-hosted GHE and `with.version` not explicitly set.

I have a pretty standard “setup python ci” flow that features a step like this:

            - name: Check for lint violations
              id: check-lint-rules
              uses: astral-sh/ruff-action@v3
              with:
                  args: check --output-format=github .

When running on self-hosted GHA runners (because self-hosted GHE instance), I get the following error (this is with debug logs on):

##[debug]=> true
##[debug]Result: true
##[debug]Starting: Check for lint violations
##[debug]Loading inputs
##[debug]Evaluating: github.workspace
##[debug]Evaluating Index:
##[debug]..Evaluating github:
##[debug]..=> Object
##[debug]..Evaluating String:
##[debug]..=> 'workspace'
##[debug]=> '/runner/_work/theRepoNameHere/theRepoNameHere'
##[debug]Result: '/runner/_work/theRepoNameHere/theRepoNameHere'
##[debug]Evaluating: github.token
##[debug]Evaluating Index:
##[debug]..Evaluating github:
##[debug]..=> Object
##[debug]..Evaluating String:
##[debug]..=> 'token'
##[debug]=> '***'
##[debug]Result: '***'
##[debug]Loading env
Run astral-sh/ruff-action@v3
  with:
    args: check --output-format=github .
    src: /runner/_work/theRepoNameHere/theRepoNameHere
    github-token: ***
  env:
    UV_CACHE_DIR: /runner/_work/_temp/setup-uv-cache
Found ruff version in pyproject.toml: >=0.[9](https://github.theInternalZoneNameHere.com/theInternalZoneNameHere/theRepoNameHere/actions/runs/124462/job/225152#step:6:9).2
##[debug]isExplicit: 
##[debug]explicit? false
Error: Not Found - https://docs.github.com/enterprise-server@3.14/rest/releases/releases#list-releases
##[debug]Node Action run completed with exit code 1
##[debug]Finishing: Check for lint violations

As the logs indicate, my pyproject.toml does feature this line:

[dependency-groups]
dev = [
    # <...>
    "ruff>=0.9.2",
]

Noting how similar the typescript code is, I figured that the same workaround here would work here:

      - name: Check for lint violations
        id: check-lint-rules
        uses: astral-sh/ruff-action@v3
        with:
          # 0.9.2 is the latest version as of 2025-01
          version: "0.9.2"
          args: check --output-format=github .

Which works!

I think the issue is here: https://github.com/astral-sh/ruff-action/blob/main/src/ruff-action.ts#L109

return await resolveVersion(versionFromPyproject || "latest", githubToken);

Which calls into this:

  if (tc.isExplicitVersion(version)) {
    core.debug(`Version ${version} is an explicit version.`);
    return version;
  }

Which - because the pyproject.toml has an expresison (>=0.9.2) not a literal (0.9.2), the if(){} is false so we execute:

const availableVersions = await getAvailableVersions(githubToken);

which - for the same reasons detailed in https://github.com/astral-sh/setup-uv/issues/221, results in an api/auth related error due to this not being “regular, public github”.


The workaround

Is to explicitly set the with.version to an explicit version. That skips the logic that assumes regular github and goes straight to the actual “plug the version into the URL template, then fetch the URL” flow which has no issues.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 17

Commits related to this issue

Most upvoted comments

Can you please try again? I implemented the try/catch

Which branch/ref?

391eb4be26373b75c81774eee2060453cae2c192