Commit Graph
230 Commits
Author SHA1 Message Date
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
Jason Ginchereau 26e77e9341 Adit fix, address copilot comments 2026-06-11 17:17:55 -07:00
Jason Ginchereau 78e3d71e19 Handle cache write error due to read-only token 2026-06-11 17:02:12 -07:00
Zachary TaylorandGitHub bd4fb086f1 Update UsageError in cache 2026-02-26 14:31:12 -05:00
Daniel KennedyandGitHub ae29a2751b @actions/cache: convert to an ESM module (#2275)
* `@actions/cache`: convert to an ESM module

* Update the fixture to ESM syntax

* Update the cache workflows

* Bump `@actions/glob` to `0.6.1`

* Fix awaiting in the cache unit tests

* Fix a type issues in contracts

* Export the `DownloadOptions`/`UploadOptions` like before

* More cache test fixes

* Make the cache units tests better

* Add some more logging

* Add retries to restore-cache.mjs
2026-01-29 14:23:32 -05:00
Ryan GhadimiandGitHub a039cff4a1 Add comment for rate limiting handling
Added a comment regarding rate limiting and retry behavior.
2026-01-16 10:26:45 +00:00
Ryan Ghadimi dd1bb93c72 New error type for cache RL 2026-01-16 10:00:15 +00:00
Ryan Ghadimi a68693e20a tests & releases 2026-01-16 09:44:57 +00:00
Ryan Ghadimi acf4bd70fb Add handling for 429s from cache service 2026-01-14 17:01:59 +00:00
Salman Muin Kayser Chishti 8a2701f328 fix(cache): replace @azure/ms-rest-js with @azure/core-rest-pipeline
Remove abandoned @azure/ms-rest-js dependency which pulls in node-fetch@v2, causing punycode deprecation warnings on Node.js 24+.

The TransferProgressEvent type is now imported from @azure/core-rest-pipeline instead.
2025-12-10 11:23:06 +00:00
Ryan Ghadimi 06f7fd9df1 new error state, tests to cover 2025-08-13 13:00:46 +00:00
Ryan Ghadimi 0fe20e9d56 remove cache size limit 2025-08-13 10:14:18 +00:00
Bassem DghaidiandGitHub 6d3feab2bf Merge pull request #2100 from actions/copilot/fix-2099
Improve cache service availability determination and implement conditional error logging
2025-07-28 16:49:10 +02:00
copilot-swe-agent[bot]andLink- bd54a2413a Fix v1 cache service to only check ACTIONS_CACHE_URL
Co-authored-by: Link- <[email protected]>
2025-07-14 13:39:13 +00:00
copilot-swe-agent[bot]andLink- d48d6b62a4 Remove logCacheError function and implement inline 5xx error detection as requested
Co-authored-by: Link- <[email protected]>
2025-07-14 12:42:37 +00:00
copilot-swe-agent[bot]andLink- c51178a15e Implement 5xx server error detection and fix most cache tests
Co-authored-by: Link- <[email protected]>
2025-07-14 12:23:44 +00:00
copilot-swe-agent[bot]andLink- cf3aaeb491 Update tests to expect warnings instead of errors for non-5xx cache failures
Co-authored-by: Link- <[email protected]>
2025-07-14 12:07:37 +00:00
Bassem DghaidiandGitHub cf4886cccb Fix linting issues 2025-07-14 03:49:28 -07:00
Bassem DghaidiandGitHub 0c5da92b52 Fix logging of cache key and restore key matches 2025-07-14 03:45:17 -07:00
copilot-swe-agent[bot]andLink- 3c90578c30 Improve cache service availability determination and change warnings to errors
- Update isFeatureAvailable() to leverage ACTIONS_CACHE_SERVICE_V2 feature flag
- For v2: check ACTIONS_RESULTS_URL availability
- For v1: check either ACTIONS_CACHE_URL or ACTIONS_RESULTS_URL availability
- Change warning logs to error logs for cache failures
- Add comprehensive tests covering all scenarios

Co-authored-by: Link- <[email protected]>
2025-07-14 10:32:34 +00:00
JoannaaKLandGitHub 857c61a9df Merge pull request #1994 from gitulisca-enterprise-cloud-testing/gitulisca/log-restore-request-version
Log cache version requested on debugging message
2025-03-17 17:58:16 +01:00
Art Leo 514314311c Log cache version requested 2025-03-15 10:13:43 +11:00
Salman Chishti 957d42e6c5 add encoding back with extra tests 2025-03-14 06:38:57 -07:00
Salman Chishti 39419dd8c3 don't need to url encode or set var 2025-03-14 06:21:41 -07:00
Salman Chishti 6876e2a664 update ts docs 2025-03-13 04:47:49 -07:00
Salman Chishti fc482662af PR feedback, back to simplified approach, no export on client as well 2025-03-13 04:23:45 -07:00
Salman Chishti abd9054c61 Log debug error when failing to decode 2025-03-12 08:14:01 -07:00
Salman Chishti 3ac34ffcb7 Mask different situations, malformed URL, encoded, decoded, raw signatures, nested parameters, and moved to a utility file 2025-03-12 03:17:35 -07:00
Salman Chishti 47c4fa85df masks the whole URL, update tests 2025-03-10 06:47:52 -07:00
Salman Chishti 1cd2f8a538 Instead of using utility method in core lib, use method in both twirp clients 2025-03-07 06:01:25 -08:00
Salman Chishti 944e6b78db Add secret and signature masking for cache and artifact packages 2025-03-06 14:25:32 -08:00
Rob Herley d096588f08 cache: wrap create failures in ReserveCacheError 2025-02-25 12:49:08 -05:00
Rob Herley e6fb8f1c5d cache miss as debug, not warning annotation 2025-02-14 09:28:01 -05:00
Rob HerleyandGitHub e0c069db55 remove runtime dependency on twirp-ts 2025-01-27 17:52:55 +00:00
Josh Gross 01f21badd5 Remove more unused cache APIs 2024-12-17 14:51:57 -05:00
Josh GrossandGitHub 26f8f84a96 Remove unused cache API (#1907) 2024-12-17 14:04:05 -05:00
Bassem DghaidiandGitHub c02c929c56 Minor comment adjustments 2024-12-02 11:10:25 -08:00
Bassem DghaidiandGitHub c649df4b94 Minor comment adjustments 2024-12-02 10:55:33 -08:00
Bassem DghaidiandGitHub fb40492b6f Merge branch 'enhance-blob-client' of github.com:actions/toolkit into enhance-blob-client 2024-12-02 10:55:00 -08:00
Bassem DghaidiandGitHub 502e8ce651 Minor comment adjustments 2024-12-02 10:53:29 -08:00
3f7df8ec5a Fix comments
Co-authored-by: Josh Gross <[email protected]>
2024-12-02 19:46:18 +01:00
b24632bd80 Fix comments
Co-authored-by: Josh Gross <[email protected]>
2024-12-02 19:46:11 +01:00
Bassem DghaidiandGitHub 792ec716de Tune upload options 2024-12-02 07:32:33 -08:00
Bassem DghaidiandGitHub a762876d6d Minor refactoring 2024-12-02 04:08:21 -08:00
Bassem DghaidiandGitHub d89855bb90 Fix upload progress bug 2024-12-02 03:55:57 -08:00
Bassem DghaidiandGitHub db1d01308c Troubleshoot 2024-12-02 03:35:20 -08:00
Bassem DghaidiandGitHub 4a272e9053 Troubleshoot 2024-12-02 03:08:05 -08:00
Bassem DghaidiandGitHub ee1c07d0aa Add error handling for failed uploads 2024-12-02 02:38:51 -08:00
Bassem DghaidiandGitHub c6f1224d30 Add progress tracking for blob uploads 2024-12-02 02:33:27 -08:00
Bassem DghaidiandGitHub 1d403c2fd8 Fix tests 2024-11-29 07:36:51 -08:00