[GH-ISSUE #2021] Artefact cache returns 400 for reserving already-reserved key, github returns 409 #970

Closed
opened 2026-03-01 21:47:49 +03:00 by kerem · 1 comment
Owner

Originally created by @huonw on GitHub (Sep 23, 2023).
Original GitHub issue: https://github.com/nektos/act/issues/2021

Bug report info

act version:            0.2.49
GOOS:                   darwin
GOARCH:                 arm64
NumCPU:                 8
Docker host:            DOCKER_HOST environment variable is not set
Sockets found:
	/var/run/docker.sock
	$HOME/.docker/run/docker.sock
Config files:           
	/Users/huon/.actrc:
		-P ubuntu-latest=catthehacker/ubuntu:act-latest
		-P ubuntu-22.04=catthehacker/ubuntu:act-22.04
		-P ubuntu-20.04=catthehacker/ubuntu:act-20.04
		-P ubuntu-18.04=catthehacker/ubuntu:act-18.04
Build info:
	Go version:            go1.20.6
	Module path:           command-line-arguments
	Main version:          
	Main path:             
	Main checksum:         
	Build settings:
		-buildmode:           exe
		-compiler:            gc
		-ldflags:             -X main.version=0.2.49
		CGO_ENABLED:          1
		CGO_CFLAGS:           
		CGO_CPPFLAGS:         
		CGO_CXXFLAGS:         
		CGO_LDFLAGS:          
		GOARCH:               arm64
		GOOS:                 darwin
Docker Engine:
	Engine version:        20.10.13
	Engine runtime:        runc
	Cgroup version:        2
	Cgroup driver:         cgroupfs
	Storage driver:        overlay2
	Registry URI:          https://index.docker.io/v1/
	OS:                    Docker Desktop
	OS type:               linux
	OS version:            
	OS arch:               aarch64
	OS kernel:             5.10.104-linuxkit
	OS CPU:                3
	OS memory:             4918 MB
	Security options:
		name=seccomp,profile=default
		name=cgroupns

Command used with act

act -W workflow.yml

Describe issue

When reserving a cache item that already exists, GitHub returns status 409 Conflict, but act returns 400 Bad Request. This means that users of the cache cannot easily distinguish an attempted overwrite (which is okay in some applications) vs. other error conditions.

The corresponding output from GitHub, has attempt-recreate include HTTP/2 409 instead of HTTP/1.1 400 for act.

No response

Workflow content

on:
  workflow_dispatch:

jobs:
  example:
    runs-on: ubuntu-20.04

    steps:
      - name: Configure env vars
        uses: actions/github-script@v6
        with:
          github-token: 1
          script: |
            core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
            core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
            core.exportVariable('KEY', `example-${Math.random().toString()}`);

      - name: create
        run: |
          curl -L -i -X POST $ACTIONS_CACHE_URL/_apis/artifactcache/caches --data '{"key": "$KEY", "version": "1"}'

      - name: attempt-recreate
        run: |
          curl -L -i -X POST $ACTIONS_CACHE_URL/_apis/artifactcache/caches --data '{"key": "$KEY", "version": "1"}'

Relevant log output

[act-cache.yml/example] ⭐ Run Main create
...
[act-cache.yml/example]   🐳  docker exec cmd=[bash --noprofile --norc -e -o pipefail /var/run/act/workflow/1] user= workdir=
| HTTP/1.1 307 Temporary Redirect
| Location: /_apis/artifactcache/caches
| Date: Sat, 23 Sep 2023 01:45:59 GMT
| Content-Length: 0
| 
| HTTP/1.1 200 OK
| Content-Type: application/json; charset=utf-8
| Date: Sat, 23 Sep 2023 01:45:59 GMT
| Content-Length: 14
| 
[act-cache.yml/example]   ✅  Success - Main create
...
[act-cache.yml/example] ⭐ Run Main attempt-recreate
...
[act-cache.yml/example]   🐳  docker exec cmd=[bash --noprofile --norc -e -o pipefail /var/run/act/workflow/2] user= workdir=
ERRO[0004] POST /_apis/artifactcache/caches: already exist  module=artifactcache
| HTTP/1.1 307 Temporary Redirect
| Location: /_apis/artifactcache/caches
| Date: Sat, 23 Sep 2023 01:46:00 GMT
| Content-Length: 0
| 
| HTTP/1.1 400 Bad Request
| Content-Type: application/json; charset=utf-8
| Date: Sat, 23 Sep 2023 01:46:00 GMT
| Content-Length: 25
| 
[act-cache.yml/example]   ✅  Success - Main attempt-recreate

Additional information

Thanks for act!

Originally created by @huonw on GitHub (Sep 23, 2023). Original GitHub issue: https://github.com/nektos/act/issues/2021 ### Bug report info ```plain text act version: 0.2.49 GOOS: darwin GOARCH: arm64 NumCPU: 8 Docker host: DOCKER_HOST environment variable is not set Sockets found: /var/run/docker.sock $HOME/.docker/run/docker.sock Config files: /Users/huon/.actrc: -P ubuntu-latest=catthehacker/ubuntu:act-latest -P ubuntu-22.04=catthehacker/ubuntu:act-22.04 -P ubuntu-20.04=catthehacker/ubuntu:act-20.04 -P ubuntu-18.04=catthehacker/ubuntu:act-18.04 Build info: Go version: go1.20.6 Module path: command-line-arguments Main version: Main path: Main checksum: Build settings: -buildmode: exe -compiler: gc -ldflags: -X main.version=0.2.49 CGO_ENABLED: 1 CGO_CFLAGS: CGO_CPPFLAGS: CGO_CXXFLAGS: CGO_LDFLAGS: GOARCH: arm64 GOOS: darwin Docker Engine: Engine version: 20.10.13 Engine runtime: runc Cgroup version: 2 Cgroup driver: cgroupfs Storage driver: overlay2 Registry URI: https://index.docker.io/v1/ OS: Docker Desktop OS type: linux OS version: OS arch: aarch64 OS kernel: 5.10.104-linuxkit OS CPU: 3 OS memory: 4918 MB Security options: name=seccomp,profile=default name=cgroupns ``` ### Command used with act ```sh act -W workflow.yml ``` ### Describe issue When reserving a cache item that already exists, GitHub returns status 409 Conflict, but act returns 400 Bad Request. This means that users of the cache cannot easily distinguish an attempted overwrite (which is okay in some applications) vs. other error conditions. The corresponding output from GitHub, has `attempt-recreate` include `HTTP/2 409` instead of `HTTP/1.1 400` for act. ### Link to GitHub repository _No response_ ### Workflow content ```yml on: workflow_dispatch: jobs: example: runs-on: ubuntu-20.04 steps: - name: Configure env vars uses: actions/github-script@v6 with: github-token: 1 script: | core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); core.exportVariable('KEY', `example-${Math.random().toString()}`); - name: create run: | curl -L -i -X POST $ACTIONS_CACHE_URL/_apis/artifactcache/caches --data '{"key": "$KEY", "version": "1"}' - name: attempt-recreate run: | curl -L -i -X POST $ACTIONS_CACHE_URL/_apis/artifactcache/caches --data '{"key": "$KEY", "version": "1"}' ``` ### Relevant log output ```sh [act-cache.yml/example] ⭐ Run Main create ... [act-cache.yml/example] 🐳 docker exec cmd=[bash --noprofile --norc -e -o pipefail /var/run/act/workflow/1] user= workdir= | HTTP/1.1 307 Temporary Redirect | Location: /_apis/artifactcache/caches | Date: Sat, 23 Sep 2023 01:45:59 GMT | Content-Length: 0 | | HTTP/1.1 200 OK | Content-Type: application/json; charset=utf-8 | Date: Sat, 23 Sep 2023 01:45:59 GMT | Content-Length: 14 | [act-cache.yml/example] ✅ Success - Main create ... [act-cache.yml/example] ⭐ Run Main attempt-recreate ... [act-cache.yml/example] 🐳 docker exec cmd=[bash --noprofile --norc -e -o pipefail /var/run/act/workflow/2] user= workdir= ERRO[0004] POST /_apis/artifactcache/caches: already exist module=artifactcache | HTTP/1.1 307 Temporary Redirect | Location: /_apis/artifactcache/caches | Date: Sat, 23 Sep 2023 01:46:00 GMT | Content-Length: 0 | | HTTP/1.1 400 Bad Request | Content-Type: application/json; charset=utf-8 | Date: Sat, 23 Sep 2023 01:46:00 GMT | Content-Length: 25 | [act-cache.yml/example] ✅ Success - Main attempt-recreate ``` ### Additional information Thanks for act!
kerem 2026-03-01 21:47:49 +03:00
Author
Owner

@github-actions[bot] commented on GitHub (Mar 22, 2024):

Issue is stale and will be closed in 14 days unless there is new activity

<!-- gh-comment-id:2014082412 --> @github-actions[bot] commented on GitHub (Mar 22, 2024): Issue is stale and will be closed in 14 days unless there is new activity
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/act#970
No description provided.