Action artifact upload from Windows act_runner results in HTTP 400 error #11738

Closed
opened 2025-11-02 09:46:18 -06:00 by GiteaMirror · 3 comments
Owner

Originally created by @s-ludwig on GitHub (Sep 27, 2023).

Originally assigned to: @fuxiaohei on GitHub.

Description

The actions/upload-artifact@v3 action (or the actions toolkit more specifically) apparently uses path.join to generate the artifact file names, resulting in a backslash character being inserted between the name and the file name/path if the workflow runs on Windows. The upload then produces an error status similar to this on the server:

::error::Unexpected response. Unable to upload chunk to http://xyz.org/api/actions_pipeline/_apis/pipelines/workflows/53/artifacts/b3900898524801ca942773cfd2301589/upload?itemPath=library-windows-x86_64%255CFreeImageLib.pdb
##### Begin Diagnostic HTTP information #####
Status Code: 400
Status Message: Bad Request
Header Information: {
  "server": "nginx",
  "date": "Wed, 27 Sep 2023 15:11:51 GMT",
  "content-type": "text/plain; charset=utf-8",
  "content-length": "22",
  "connection": "keep-alive",
  "x-content-type-options": "nosniff"
}
###### End Diagnostic HTTP information ######
::warning::Aborting upload for C:\Users\gitlab3\act_builds\e616ea9d8027ca3a\hostexecutor\Source\FreeImageLib\x64\Release\FreeImageLib.pdb due to failure
::error::aborting artifact upload

Gitea Version

1.21

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

No response

Git Version

2.34.1

Operating System

Linux

How are you running Gitea?

Using the official download binary and using act_runner 0.2.6 on Windows.

Database

MySQL/MariaDB

Originally created by @s-ludwig on GitHub (Sep 27, 2023). Originally assigned to: @fuxiaohei on GitHub. ### Description The `actions/upload-artifact@v3` action (or the actions toolkit more specifically) apparently [uses `path.join`](https://github.com/actions/toolkit/blob/master/packages/artifact/src/internal/upload-specification.ts#L87) to generate the artifact file names, resulting in a backslash character being inserted between the name and the file name/path if the workflow runs on Windows. The upload then produces an error status similar to this on the server: ``` ::error::Unexpected response. Unable to upload chunk to http://xyz.org/api/actions_pipeline/_apis/pipelines/workflows/53/artifacts/b3900898524801ca942773cfd2301589/upload?itemPath=library-windows-x86_64%255CFreeImageLib.pdb ##### Begin Diagnostic HTTP information ##### Status Code: 400 Status Message: Bad Request Header Information: { "server": "nginx", "date": "Wed, 27 Sep 2023 15:11:51 GMT", "content-type": "text/plain; charset=utf-8", "content-length": "22", "connection": "keep-alive", "x-content-type-options": "nosniff" } ###### End Diagnostic HTTP information ###### ::warning::Aborting upload for C:\Users\gitlab3\act_builds\e616ea9d8027ca3a\hostexecutor\Source\FreeImageLib\x64\Release\FreeImageLib.pdb due to failure ::error::aborting artifact upload ``` ### Gitea Version 1.21 ### Can you reproduce the bug on the Gitea demo site? No ### Log Gist _No response_ ### Screenshots _No response_ ### Git Version 2.34.1 ### Operating System Linux ### How are you running Gitea? Using the official download binary and using act_runner 0.2.6 on Windows. ### Database MySQL/MariaDB
GiteaMirror added the issue/confirmedtype/bug labels 2025-11-02 09:46:18 -06:00
Author
Owner

@psaintmalo commented on GitHub (Oct 13, 2023):

Can confirm the same issue happening to me with 1.21rc1 and the 0.2.6 action runner binaries.
This is the upload actions:

     - name: Upload Action Artifact
         uses: actions/upload-artifact@v3
         with:
           name: program_${{ runner.OS }}_${{ matrix.target }}.exe
           path: target/${{ matrix.target }}/release/program.exe

Works fine with the linux action runner but wont upload with the windows action runner.
Action runner is being executed in Ghost Spectre Windows 10 22H2.

@psaintmalo commented on GitHub (Oct 13, 2023): Can confirm the same issue happening to me with 1.21rc1 and the 0.2.6 action runner binaries. This is the upload actions: ``` - name: Upload Action Artifact uses: actions/upload-artifact@v3 with: name: program_${{ runner.OS }}_${{ matrix.target }}.exe path: target/${{ matrix.target }}/release/program.exe ``` Works fine with the linux action runner but wont upload with the windows action runner. Action runner is being executed in Ghost Spectre Windows 10 22H2.
Author
Owner

@psaintmalo commented on GitHub (Oct 14, 2023):

Looking further into the code myself, the backslash that is being inserted might be from safeResolve function used in netkos/act/pkg/artifacts/server.go.

return filepath.Join(baseDir, filepath.Clean(filepath.Join(string(os.PathSeparator), relPath)))

The safeResolve function is then used for the uploads function, which forms part of the Serve function.

The nektos/act/pkg/artifacts is being imported by act_runner in exec.go which then uses the Serve function.

As safeResolves uses the os.PathSeparator, it would default to backslash instead of forward slash for Windows.

Act_runner issue #375.

@psaintmalo commented on GitHub (Oct 14, 2023): Looking further into the code myself, the backslash that is being inserted might be from [safeResolve](https://github.com/nektos/act/blob/ace4cd47c7f099864866b1f60e064fecde7f36ea/pkg/artifacts/server.go#L92) function used in [netkos/act](https://github.com/nektos/act/tree/master)/[pkg](https://github.com/nektos/act/tree/master/pkg)/[artifacts](https://github.com/nektos/act/tree/master/pkg/artifacts)/server.go. `return filepath.Join(baseDir, filepath.Clean(filepath.Join(string(os.PathSeparator), relPath)))` The safeResolve function is then used for the [uploads](https://github.com/nektos/act/blob/ace4cd47c7f099864866b1f60e064fecde7f36ea/pkg/artifacts/server.go#L120) function, which forms part of the [Serve](https://github.com/nektos/act/blob/ace4cd47c7f099864866b1f60e064fecde7f36ea/pkg/artifacts/server.go#L290) function. The nektos/act/pkg/artifacts is being imported by act_runner in [exec.go](https://gitea.com/gitea/act_runner/src/commit/4c3528817525860ae84c8a5eda19eaced31c58cb/internal/app/cmd/exec.go#L19) which then uses the [Serve function](https://gitea.com/gitea/act_runner/src/commit/4c3528817525860ae84c8a5eda19eaced31c58cb/internal/app/cmd/exec.go#L435). As safeResolves uses the os.PathSeparator, it would default to backslash instead of forward slash for Windows. Act_runner issue [#375](https://gitea.com/gitea/act_runner/issues/375).
Author
Owner

@fuxiaohei commented on GitHub (Nov 9, 2023):

Fixed in https://github.com/go-gitea/gitea/pull/27840

@fuxiaohei commented on GitHub (Nov 9, 2023): Fixed in https://github.com/go-gitea/gitea/pull/27840
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#11738