@@ -39023,7 +39023,7 @@ module.exports = { version: packageJson.version }
3902339023/***/ 4012:
3902439024/***/ ((module) => {
3902539025
39026- module.exports = /*#__PURE__*/JSON.parse('{"name":"@actions/cache","version":"6.1.0","description":"Actions cache lib","keywords":["github","actions","cache"],"homepage":"https://github.com/actions/toolkit/tree/main/packages/cache","license":"MIT","type":"module","main":"lib/cache.js","types":"lib/cache.d.ts","exports":{".":{"types":"./lib/cache.d.ts","import":"./lib/cache.js"}},"directories":{"lib":"lib","test":"__tests__"},"files":["lib","!.DS_Store"],"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/actions/toolkit.git","directory":"packages/cache"},"scripts":{"audit-moderate":"npm install && npm audit --json --audit-level=moderate > audit.json","test":"echo \\"Error: run tests from root\\" && exit 1","tsc":"tsc && cp src/internal/shared/package-version.cjs lib/internal/shared/"},"bugs":{"url":"https://github.com/actions/toolkit/issues"},"dependencies":{"@actions/core":"^3.0.1","@actions/exec":"^3.0.0","@actions/glob":"^0.6.1","@actions/http-client":"^4.0.1","@actions/io":"^3.0.2","@azure/core-rest-pipeline":"^1.23.0","@azure/storage-blob":"^12.31.0","@protobuf-ts/runtime-rpc":"^2.11.1","semver":"^7.7.4"},"devDependencies":{"@protobuf-ts/plugin":"^2.11.1","@types/node":"^25.6.0","@types/semver":"^7.7.1","typescript":"^5.9.3"},"overrides":{"uri-js":"npm:uri-js-replace@^1.0.1","node-fetch":"^3.3.2"}}');
39026+ module.exports = /*#__PURE__*/JSON.parse('{"name":"@actions/cache","version":"6.2.0","description":"Actions cache lib","keywords":["github","actions","cache"],"homepage":"https://github.com/actions/toolkit/tree/main/packages/cache","license":"MIT","type":"module","main":"lib/cache.js","types":"lib/cache.d.ts","exports":{".":{"types":"./lib/cache.d.ts","import":"./lib/cache.js"}},"directories":{"lib":"lib","test":"__tests__"},"files":["lib","!.DS_Store"],"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/actions/toolkit.git","directory":"packages/cache"},"scripts":{"audit-moderate":"npm install && npm audit --json --audit-level=moderate > audit.json","test":"echo \\"Error: run tests from root\\" && exit 1","tsc":"tsc && cp src/internal/shared/package-version.cjs lib/internal/shared/"},"bugs":{"url":"https://github.com/actions/toolkit/issues"},"dependencies":{"@actions/core":"^3.0.1","@actions/exec":"^3.0.0","@actions/glob":"^0.6.1","@actions/http-client":"^4.0.1","@actions/io":"^3.0.2","@azure/core-rest-pipeline":"^1.23.0","@azure/storage-blob":"^12.31.0","@protobuf-ts/runtime-rpc":"^2.11.1","semver":"^7.7.4"},"devDependencies":{"@protobuf-ts/plugin":"^2.11.1","@types/node":"^25.6.0","@types/semver":"^7.7.1","typescript":"^5.9.3"},"overrides":{"uri-js":"npm:uri-js-replace@^1.0.1","node-fetch":"^3.3.2"}}');
3902739027
3902839028/***/ })
3902939029
@@ -43274,6 +43274,10 @@ const SystemTarPathOnWindows = `${process.env['SYSTEMDRIVE']}\\Windows\\System32
4327443274const TarFilename = 'cache.tar';
4327543275const ManifestFilename = 'manifest.txt';
4327643276const CacheFileSizeLimit = 10 * Math.pow(1024, 3); // 10GiB per repository
43277+ // Prefix the cache backend embeds in a read-denial message (v2 twirp
43278+ // GetCacheEntryDownloadURL error or the GHES v1 `_apis/artifactcache` 403 body).
43279+ // Shared so cache.ts and cacheHttpClient.ts match the same contract value.
43280+ const constants_CacheReadDeniedMessagePrefix = 'cache read denied:';
4327743281//# sourceMappingURL=constants.js.map
4327843282;// CONCATENATED MODULE: ./node_modules/@actions/cache/lib/internal/cacheUtils.js
4327943283var cacheUtils_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
@@ -92979,6 +92983,24 @@ function config_getCacheServiceVersion() {
9297992983 return 'v1';
9298092984 return process.env['ACTIONS_CACHE_SERVICE_V2'] ? 'v2' : 'v1';
9298192985}
92986+ // The cache-mode lattice: readable = {read, write}, writable = {write,
92987+ // write-only}, none = neither.
92988+ const KNOWN_CACHE_MODES = ['none', 'read', 'write', 'write-only'];
92989+ // The effective cache-mode exported by the runner, or '' when not set.
92990+ function config_getCacheMode() {
92991+ return (process.env['ACTIONS_CACHE_MODE'] || '').trim().toLowerCase();
92992+ }
92993+ // Unset or unrecognized modes are permissive so behavior matches today.
92994+ function config_isCacheReadable(mode) {
92995+ if (!KNOWN_CACHE_MODES.includes(mode))
92996+ return true;
92997+ return mode === 'read' || mode === 'write';
92998+ }
92999+ function isCacheWritable(mode) {
93000+ if (!KNOWN_CACHE_MODES.includes(mode))
93001+ return true;
93002+ return mode === 'write' || mode === 'write-only';
93003+ }
9298293004function getCacheServiceURL() {
9298393005 const version = config_getCacheServiceVersion();
9298493006 // Based on the version of the cache service, we will determine which
@@ -93028,6 +93050,7 @@ var cacheHttpClient_awaiter = (undefined && undefined.__awaiter) || function (th
9302893050
9302993051
9303093052
93053+
9303193054function getCacheApiUrl(resource) {
9303293055 const baseUrl = getCacheServiceURL();
9303393056 if (!baseUrl) {
@@ -93055,6 +93078,7 @@ function createHttpClient() {
9305593078}
9305693079function getCacheEntry(keys, paths, options) {
9305793080 return cacheHttpClient_awaiter(this, void 0, void 0, function* () {
93081+ var _a;
9305893082 const httpClient = createHttpClient();
9305993083 const version = utils.getCacheVersion(paths, options === null || options === void 0 ? void 0 : options.compressionMethod, options === null || options === void 0 ? void 0 : options.enableCrossOsArchive);
9306093084 const resource = `cache?keys=${encodeURIComponent(keys.join(','))}&version=${version}`;
@@ -93068,6 +93092,12 @@ function getCacheEntry(keys, paths, options) {
9306893092 return null;
9306993093 }
9307093094 if (!isSuccessStatusCode(response.statusCode)) {
93095+ // Only surface the receiver's body for a `cache read denied:` policy denial
93096+ // so callers can dispatch on it; keep the generic message otherwise.
93097+ const errorMessage = (_a = response.error) === null || _a === void 0 ? void 0 : _a.message;
93098+ if (errorMessage === null || errorMessage === void 0 ? void 0 : errorMessage.includes(CacheReadDeniedMessagePrefix)) {
93099+ throw new Error(errorMessage);
93100+ }
9307193101 throw new Error(`Cache service responded with ${response.statusCode}`);
9307293102 }
9307393103 const cacheResult = response.result;
@@ -94328,6 +94358,7 @@ var cache_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _ar
9432894358
9432994359
9433094360
94361+
9433194362class ValidationError extends Error {
9433294363 constructor(message) {
9433394364 super(message);
@@ -94343,19 +94374,20 @@ class ReserveCacheError extends Error {
9434394374 }
9434494375}
9434594376/**
94346- * Stable prefix the receiver writes into the cache reservation response when
94347- * the issuer downgraded the cache token to read-only (for example, because
94377+ * Stable prefix the cache service writes into the cache reservation response
94378+ * when the issuer downgraded the cache token to read-only (for example, because
9434894379 * the run was triggered by an untrusted event). saveCacheV1 / saveCacheV2
94349- * dispatch on this prefix to re-classify the failure as a
94350- * CacheWriteDeniedError so consumers (and the outer catch arm) can
94351- * distinguish a policy denial from other reservation failures.
94380+ * dispatch on this prefix to re-classify the failure as a CacheWriteDeniedError
94381+ * so consumers and tests can distinguish a policy denial from other reservation
94382+ * failures. Internally it is logged as a non-fatal warning like other
94383+ * best-effort save failures.
9435294384 */
9435394385const CACHE_WRITE_DENIED_PREFIX = 'cache write denied:';
9435494386/**
9435594387 * Raised when the cache backend refuses to reserve a writable cache entry
9435694388 * because the JWT issued for this run was scoped read-only (for example, the
9435794389 * run was triggered by an event the repository administrator classified as
94358- * untrusted). The receiver -supplied detail message always begins with
94390+ * untrusted). The service -supplied detail message always begins with
9435994391 * `cache write denied:` (the full error message includes additional context
9436094392 * like the cache key).
9436194393 *
@@ -94371,6 +94403,19 @@ class CacheWriteDeniedError extends ReserveCacheError {
9437194403 Object.setPrototypeOf(this, CacheWriteDeniedError.prototype);
9437294404 }
9437394405}
94406+ // Re-exported from constants so consumers keep referencing it here; the shared
94407+ // value also drives detection in cacheHttpClient without duplicating the string.
94408+ const CACHE_READ_DENIED_PREFIX = (/* unused pure expression or super */ null && (CacheReadDeniedMessagePrefix));
94409+ // Raised when the cache backend denies a download URL because the run's token
94410+ // has no readable cache scopes. Caching is best-effort, so restoreCache logs a
94411+ // warning and reports a cache miss rather than rethrowing this.
94412+ class CacheReadDeniedError extends Error {
94413+ constructor(message) {
94414+ super(message);
94415+ this.name = 'CacheReadDeniedError';
94416+ Object.setPrototypeOf(this, CacheReadDeniedError.prototype);
94417+ }
94418+ }
9437494419class FinalizeCacheError extends Error {
9437594420 constructor(message) {
9437694421 super(message);
@@ -94425,6 +94470,12 @@ function restoreCache(paths_1, primaryKey_1, restoreKeys_1, options_1) {
9442594470 const cacheServiceVersion = getCacheServiceVersion();
9442694471 core.debug(`Cache service version: ${cacheServiceVersion}`);
9442794472 checkPaths(paths);
94473+ const cacheMode = getCacheMode();
94474+ if (!isCacheReadable(cacheMode)) {
94475+ core.info(`Cache restore skipped: the effective cache-mode '${cacheMode}' does not permit reads.`);
94476+ core.debug(`Skipped restore for paths [${paths.join(', ')}] with primary key '${primaryKey}'.`);
94477+ return undefined;
94478+ }
9442894479 switch (cacheServiceVersion) {
9442994480 case 'v2':
9443094481 return yield restoreCacheV2(paths, primaryKey, restoreKeys, options, enableCrossOsArchive);
@@ -94446,6 +94497,7 @@ function restoreCache(paths_1, primaryKey_1, restoreKeys_1, options_1) {
9444694497 */
9444794498function restoreCacheV1(paths_1, primaryKey_1, restoreKeys_1, options_1) {
9444894499 return cache_awaiter(this, arguments, void 0, function* (paths, primaryKey, restoreKeys, options, enableCrossOsArchive = false) {
94500+ var _a;
9444994501 restoreKeys = restoreKeys || [];
9445094502 const keys = [primaryKey, ...restoreKeys];
9445194503 core.debug('Resolved Keys:');
@@ -94460,10 +94512,26 @@ function restoreCacheV1(paths_1, primaryKey_1, restoreKeys_1, options_1) {
9446094512 let archivePath = '';
9446194513 try {
9446294514 // path are needed to compute version
94463- const cacheEntry = yield cacheHttpClient.getCacheEntry(keys, paths, {
94464- compressionMethod,
94465- enableCrossOsArchive
94466- });
94515+ let cacheEntry;
94516+ try {
94517+ cacheEntry = yield cacheHttpClient.getCacheEntry(keys, paths, {
94518+ compressionMethod,
94519+ enableCrossOsArchive
94520+ });
94521+ }
94522+ catch (error) {
94523+ // The v1 artifact cache service returns HTTP 403 with a
94524+ // `cache read denied:` body when the run's token has no readable cache
94525+ // scopes. getCacheEntry lives in a dependency-free internal module and
94526+ // cannot import CacheReadDeniedError without a circular dependency, so it
94527+ // only surfaces the raw denial message; we classify it into the typed
94528+ // error here so the outer catch and consumers can dispatch on it.
94529+ const errorMessage = (_a = error === null || error === void 0 ? void 0 : error.message) !== null && _a !== void 0 ? _a : '';
94530+ if (errorMessage.includes(CACHE_READ_DENIED_PREFIX)) {
94531+ throw new CacheReadDeniedError(errorMessage);
94532+ }
94533+ throw error;
94534+ }
9446794535 if (!(cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.archiveLocation)) {
9446894536 // Cache not found
9446994537 return undefined;
@@ -94492,7 +94560,9 @@ function restoreCacheV1(paths_1, primaryKey_1, restoreKeys_1, options_1) {
9449294560 }
9449394561 else {
9449494562 // warn on cache restore failure and continue build
94495- // Log server errors (5xx) as errors, all other errors as warnings
94563+ // Log server errors (5xx) as errors, all other errors as warnings.
94564+ // A read denied by policy (CacheReadDeniedError) is not an HttpClientError
94565+ // so it falls here and is warned, treated as a cache miss.
9449694566 if (typedError instanceof HttpClientError &&
9449794567 typeof typedError.statusCode === 'number' &&
9449894568 typedError.statusCode >= 500) {
@@ -94527,6 +94597,7 @@ function restoreCacheV1(paths_1, primaryKey_1, restoreKeys_1, options_1) {
9452794597 */
9452894598function restoreCacheV2(paths_1, primaryKey_1, restoreKeys_1, options_1) {
9452994599 return cache_awaiter(this, arguments, void 0, function* (paths, primaryKey, restoreKeys, options, enableCrossOsArchive = false) {
94600+ var _a;
9453094601 // Override UploadOptions to force the use of Azure
9453194602 options = Object.assign(Object.assign({}, options), { useAzureSdk: true });
9453294603 restoreKeys = restoreKeys || [];
@@ -94548,7 +94619,20 @@ function restoreCacheV2(paths_1, primaryKey_1, restoreKeys_1, options_1) {
9454894619 restoreKeys,
9454994620 version: utils.getCacheVersion(paths, compressionMethod, enableCrossOsArchive)
9455094621 };
94551- const response = yield twirpClient.GetCacheEntryDownloadURL(request);
94622+ let response;
94623+ try {
94624+ response = yield twirpClient.GetCacheEntryDownloadURL(request);
94625+ }
94626+ catch (error) {
94627+ // The receiver returns twirp PermissionDenied (403) when the run's token
94628+ // has no readable cache scopes. The client wraps that 403, so the stable
94629+ // prefix is embedded in the message rather than leading it.
94630+ const errorMessage = (_a = error === null || error === void 0 ? void 0 : error.message) !== null && _a !== void 0 ? _a : '';
94631+ if (errorMessage.includes(CACHE_READ_DENIED_PREFIX)) {
94632+ throw new CacheReadDeniedError(errorMessage);
94633+ }
94634+ throw error;
94635+ }
9455294636 if (!response.ok) {
9455394637 core.debug(`Cache not found for version ${request.version} of keys: ${keys.join(', ')}`);
9455494638 return undefined;
@@ -94583,8 +94667,10 @@ function restoreCacheV2(paths_1, primaryKey_1, restoreKeys_1, options_1) {
9458394667 throw error;
9458494668 }
9458594669 else {
94586- // Supress all non-validation cache related errors because caching should be optional
94587- // Log server errors (5xx) as errors, all other errors as warnings
94670+ // Suppress all non-validation cache related errors because caching should be optional
94671+ // Log server errors (5xx) as errors, all other errors as warnings.
94672+ // A read denied by policy (CacheReadDeniedError) is not an HttpClientError
94673+ // so it falls here and is warned, treated as a cache miss.
9458894674 if (typedError instanceof HttpClientError &&
9458994675 typeof typedError.statusCode === 'number' &&
9459094676 typedError.statusCode >= 500) {
@@ -94623,6 +94709,12 @@ function cache_saveCache(paths_1, key_1, options_1) {
9462394709 core_debug(`Cache service version: ${cacheServiceVersion}`);
9462494710 checkPaths(paths);
9462594711 checkKey(key);
94712+ const cacheMode = config_getCacheMode();
94713+ if (!isCacheWritable(cacheMode)) {
94714+ info(`Cache save skipped: the effective cache-mode '${cacheMode}' does not permit writes.`);
94715+ core_debug(`Skipped save for paths [${paths.join(', ')}] with key '${key}'.`);
94716+ return -1;
94717+ }
9462694718 switch (cacheServiceVersion) {
9462794719 case 'v2':
9462894720 return yield saveCacheV2(paths, key, options, enableCrossOsArchive);
@@ -94700,17 +94792,14 @@ function saveCacheV1(paths_1, key_1, options_1) {
9470094792 if (typedError.name === ValidationError.name) {
9470194793 throw error;
9470294794 }
94703- else if (typedError.name === CacheWriteDeniedError.name) {
94704- // Cache write was denied by policy (read-only token). Surface to the
94705- // customer at warning level so it is visible in the workflow log
94706- // without failing the run.
94707- warning(`Failed to save: ${typedError.message}`);
94708- }
9470994795 else if (typedError.name === ReserveCacheError.name) {
9471094796 info(`Failed to save: ${typedError.message}`);
9471194797 }
9471294798 else {
94713- // Log server errors (5xx) as errors, all other errors as warnings
94799+ // Log server errors (5xx) as errors, all other errors as warnings.
94800+ // A write denied by policy (CacheWriteDeniedError) is not an
94801+ // HttpClientError and its name does not match the ReserveCacheError arm,
94802+ // so it falls here and is warned without failing the run.
9471494803 if (typedError instanceof lib_HttpClientError &&
9471594804 typeof typedError.statusCode === 'number' &&
9471694805 typedError.statusCode >= 500) {
@@ -94821,20 +94910,17 @@ function saveCacheV2(paths_1, key_1, options_1) {
9482194910 if (typedError.name === ValidationError.name) {
9482294911 throw error;
9482394912 }
94824- else if (typedError.name === CacheWriteDeniedError.name) {
94825- // Cache write was denied by policy (read-only token). Surface to the
94826- // customer at warning level so it is visible in the workflow log
94827- // without failing the run.
94828- warning(`Failed to save: ${typedError.message}`);
94829- }
9483094913 else if (typedError.name === ReserveCacheError.name) {
9483194914 info(`Failed to save: ${typedError.message}`);
9483294915 }
9483394916 else if (typedError.name === FinalizeCacheError.name) {
9483494917 warning(typedError.message);
9483594918 }
9483694919 else {
94837- // Log server errors (5xx) as errors, all other errors as warnings
94920+ // Log server errors (5xx) as errors, all other errors as warnings.
94921+ // A write denied by policy (CacheWriteDeniedError) is not an
94922+ // HttpClientError and its name does not match the ReserveCacheError arm,
94923+ // so it falls here and is warned without failing the run.
9483894924 if (typedError instanceof lib_HttpClientError &&
9483994925 typeof typedError.statusCode === 'number' &&
9484094926 typedError.statusCode >= 500) {
0 commit comments