Files
ffdc20ef92 feat(cache): add cache-mode client behavior (read-denied warning + ACTIONS_CACHE_MODE skip) (#2447)
* feat(cache): surface cache read-denied as a distinct restore warning

Mirror the existing cache write-denied handling on the restore path. When
the receiver refuses a download URL because the run's token has no readable
cache scopes, it returns a twirp PermissionDenied (HTTP 403). The twirp
client wraps that 403 in a generic Error, so the stable 'cache read denied:'
prefix is embedded in the message rather than at the start.

- Add CACHE_READ_DENIED_PREFIX and CacheReadDeniedError
- Dispatch on the prefix in the restoreCacheV2 catch block (V2 only), log a
  policy-specific warning, and report a cache miss so the run continues
- Add a test mirroring the write-denied coverage

* chore(cache): trim comments, bump to 6.2.0, add RELEASES entry

* refactor(cache): dispatch read-denied by error name to mirror write path

Re-throw CacheReadDeniedError from an inner try/catch around
GetCacheEntryDownloadURL and dispatch on typedError.name in the outer catch,
matching how saveCacheV2 handles CacheWriteDeniedError.

* feat(cache): handle read-denied on the v1 restore path

Extend the read-denied handling to Cache Service v1 so GHES (which forces v1
via _apis/artifactcache) is covered when read-scope enforcement ships there.

- Surface the receiver's error body message from getCacheEntry instead of a
  generic status-code error, so the cache read denied: prefix reaches callers
- Re-throw CacheReadDeniedError from restoreCacheV1 and dispatch on it in the
  outer catch, mirroring restoreCacheV2 and the write-denied v1 handling
- Add a v1 read-denied test

* refactor(cache): only surface receiver body for read-denied on v1

* test(cache): assert getCacheEntry only surfaces body for read-denied

* test(cache): cover non-read-denied getCacheEntry passthrough on v1

* refactor(cache): share read-denied prefix via constants to avoid drift

* feat(cache): skip restore/save per ACTIONS_CACHE_MODE

* test(cache): expand ACTIONS_CACHE_MODE skip coverage across v1/v2 and unknown modes

* fix copilot pr feedback

Co-authored-by: Copilot Autofix powered by AI <[email protected]>

* docs(cache): remove internal reference from cache-mode comment

* test(cache): merge redundant cache-mode skip tests and simplify read-denied handling

Address PR review feedback:
- Merge the duplicate restore/save skip test.each blocks into single blocks parametrized over ACTIONS_CACHE_SERVICE_V2.
- Drop the redundant CacheReadDeniedError catch arms; the typed error is not an HttpClientError so it already falls through to a non-fatal warning.
- Clarify why read-denied classification happens both in getCacheEntry and cache.ts (dependency-free internal module cannot import the typed error).

* refactor(cache): drop redundant CacheWriteDeniedError catch arms

Mirror the read-denied simplification on the save path. CacheWriteDeniedError
is not an HttpClientError and its name does not match the ReserveCacheError
arm, so it falls through to the same non-fatal warning. Logging behavior is
unchanged (warns, never fails the run) and the exported type is still thrown
internally for consumers and tests. Also refresh stale doc wording.

* test(cache): collapse redundant restore getCacheEntry-failure tests

The two restoreCache tests exercised the identical warning + cache-miss path
now that read-denied is no longer reclassified in the catch, so merge them into
one. The read-denied prefix detection that actually branches on the message is
covered by getCacheEntry tests in cacheHttpClient.test.ts.

---------

Co-authored-by: Copilot Autofix powered by AI <[email protected]>
2026-07-13 10:03:16 -05:00

11 KiB

@actions/cache Releases

6.2.0

  • Handle cache read error due to read-only token: detect the cache read denied: prefix on cache download failures (both the v2 twirp path and the v1 _apis/artifactcache path) and surface it as a core.warning (without failing the run).
  • Honor the ACTIONS_CACHE_MODE environment variable: skip restore when the effective cache-mode does not permit reads (none, write-only) and skip save when it does not permit writes (none, read), logging a single non-fatal core.info line. When ACTIONS_CACHE_MODE is unset or unrecognized, behavior is unchanged.

6.1.0

  • Handle cache write error due to read-only token: detect the cache write denied: prefix on cache reservation failures and surface it as a core.warning (without failing the run).

6.0.1

  • Bump dependency versions (#2393):
    • @actions/core to ^3.0.1
    • @actions/http-client to ^4.0.1
    • @actions/io to ^3.0.2
    • @azure/core-rest-pipeline to ^1.23.0
    • @azure/storage-blob to ^12.31.0
    • semver to ^7.7.4

6.0.0

  • Breaking change: Package is now ESM-only
    • CommonJS consumers must use dynamic import() instead of require()

5.0.5

  • Bump @actions/glob to 0.5.1

5.0.4

  • Bump @actions/http-client to 3.0.2

5.0.3

Prevent retries for rate limited cache operations 2243.

5.0.1

  • Fix Node.js 24 punycode deprecation warning by updating @azure/storage-blob from ^12.13.0 to ^12.29.1 #2213
  • Newer storage-blob uses @azure/core-rest-pipeline instead of deprecated @azure/core-http, which eliminates the transitive dependency on node-fetch@2whatwg-url@5[email protected] that used the deprecated punycode module

5.0.0

  • Remove @azure/ms-rest-js dependency #2197
    • The TransferProgressEvent type is now imported from @azure/core-rest-pipeline instead of @azure/ms-rest-js
  • Bump @actions/core from ^1.11.1 to ^2.0.0 #2198
  • Bump @actions/exec from ^1.0.1 to ^2.0.0 #2198
  • Bump @actions/glob from ^0.1.0 to ^0.5.0 #2198
  • Bump @actions/http-client from ^2.1.1 to ^3.0.0 #2198
  • Bump @actions/io from ^1.0.1 to ^2.0.0 #2198
  • Add support for Node.js 24 #2110
  • Add node-fetch override to resolve audit vulnerabilities #2110

4.1.0

  • Remove client side 10GiB cache size limit check & update twirp client #2118

4.0.5

  • Reintroduce @protobuf-ts/runtime-rpc as a runtime dependency #2113

4.0.4

⚠️ Faulty patch release. Upgrade to 4.0.5 instead.

  • Optimized cache dependencies by moving @protobuf-ts/plugin to dev dependencies #2106
  • Improved cache service availability determination for different cache service versions (v1 and v2) #2100
  • Enhanced server error handling: 5xx HTTP errors are now logged as errors instead of warnings #2099
  • Fixed cache hit logging to properly distinguish between exact key matches and restore key matches #2101

4.0.3

  • Added masking for Shared Access Signature (SAS) cache entry URLs #1982
  • Improved debugging by logging both the cache version alongside the keys requested when a cache restore fails #1994

4.0.2

  • Wrap create failures in ReserveCacheError #1966

4.0.1

  • Remove runtime dependency on twirp-ts #1947
  • Cache miss as debug, not warning annotation #1954

4.0.0

Important changes

The cache backend service has been rewritten from the ground up for improved performance and reliability. The @actions/cache package now integrates with the new cache service (v2) APIs.

The new service will gradually roll out as of February 1st, 2025. The legacy service will also be sunset on the same date. Changes in this release are fully backward compatible.

All previous versions of this package will be deprecated. We recommend upgrading to version 4.0.0 as soon as possible before February 1st, 2025.

If you do not upgrade, all workflow runs using any of the deprecated @actions/cache packages will fail.

Upgrading to the recommended version should not break or require any changes to your workflows beyond updating your package.json to version 4.0.0.

Read more about the change & access the migration guide: reference to the announcement.

Minor changes

  • Update @actions/core to 1.11.0
  • Update semver 6.3.1
  • Add twirp-ts 2.5.0 to dependencies

3.3.0

  • Update @actions/core to 1.11.1
  • Remove dependency on uuid package #1824, #1842

3.2.4

  • Updated isGhes check to include .ghe.com and .ghe.localhost as accepted hosts

3.2.3

  • Fixed a bug that mutated path arguments to getCacheVersion #1378

3.2.2

  • Add new default cache download method to improve performance and reduce hangs #1484

3.2.1

  • Updated @azure/storage-blob to v12.13.0

3.2.0

  • Add lookupOnly to cache restore DownloadOptions.

3.1.4

  • Fix zstd not being used due to zstd --version output change in zstd 1.5.4 release. See #1353.

3.1.3

  • Fix to prevent from setting MYSYS environement variable globally #1329.

3.1.2

  • Fix issue with symlink restoration on windows.

3.1.1

  • Reverted changes in 3.1.0 to fix issue with symlink restoration on windows.
  • Added support for verbose logging about cache version during cache miss.

3.1.0

  • Update actions/cache on windows to use gnu tar and zstd by default
  • Update actions/cache on windows to fallback to bsdtar and zstd if gnu tar is not available.
  • Added support for fallback to gzip to restore old caches on windows.

3.1.0-beta.3

  • Bug Fixes for fallback to gzip to restore old caches on windows and bsdtar if gnutar is not available.

3.1.0-beta.2

  • Added support for fallback to gzip to restore old caches on windows.

3.0.6

  • Added @azure/abort-controller to dependencies to fix compatibility issue with ESM #1208

3.0.5

  • Update @actions/cache to use @actions/core@^1.10.0

3.0.4

  • Fix zstd not working for windows on gnu tar in issues #888 and #891.
  • Allowing users to provide a custom timeout as input for aborting download of a cache segment using an environment variable SEGMENT_DOWNLOAD_TIMEOUT_MINS. Default is 60 minutes.

3.0.3

  • Bug fixes for download stuck issue #810.

3.0.2

  • Added 1 hour timeout for the download stuck issue #810.

3.0.1

  • Fix #833 - cache doesn't work with github workspace directory.
  • Fix #809 zstd -d: no such file or directory error on AWS self-hosted runners.

3.0.0

  • Updated actions/cache to suppress Actions cache server error and log warning for those error #1122

2.0.6

  • Fix Tar failed with error: The process '/usr/bin/tar' failed with exit code 1 issue when temp directory where tar is getting created is actually the subdirectory of the path mentioned by the user for caching. (issue)

2.0.5

  • Fix to avoid saving empty cache when no files are available for caching. (issue)

2.0.4

  • Update to v2.0.1 of @actions/http-client #1087

2.0.3

  • Update to v2.0.0 of @actions/http-client

2.0.0

  • Added support to check if Actions cache service feature is available or not #1028

1.0.11

  • Fix file downloads > 2GB(issue)

1.0.10

  • Update lockfileVersion to v2 in `package-lock.json #1022

1.0.9

  • Use @azure/ms-rest-js v2.6.0
  • Use @azure/storage-blob v12.8.0

1.0.8

  • Increase the allowed artifact cache size from 5GB to 10GB (issue)

1.0.7

  • Fixes permissions issue extracting archives with GNU tar on macOS (issue)

1.0.6

  • Make caching more verbose #650
  • Use GNU tar on macOS if available #701

1.0.5

  • Fix to ensure Windows cache paths get resolved correctly

1.0.4

  • Use @actions/core v1.2.6
  • Fixes uploadChunk to throw an error if any unsuccessful response code is received

1.0.3

  • Use http-client v1.0.9
  • Fixes error handling so retries are not attempted on non-retryable errors (409 Conflict, for example)
  • Adds 5 second delay between retry attempts

1.0.2

  • Use posix archive format to add support for some tools

1.0.1

  • Fix bug in downloading large files (> 2 GBs) with the Azure SDK

1.0.0

  • Downloads Azure-hosted caches using the Azure SDK for speed and reliability
  • Displays download progress
  • Includes changes that break compatibility with earlier versions, including:
    • retry, retryTypedResponse, and retryHttpClientResponse moved from cacheHttpClient to requestUtils

0.2.1

  • Fix to await async function getCompressionMethod

0.2.0

  • Fixes issues with the zstd compression algorithm on Windows and Ubuntu 16.04 #469

0.1.0

  • Initial release