You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import*ascachefrom"@actions/cache";constpaths=["some/paths"];constkey="a-key";// This calls `getCacheVersion` internally and mutates `paths`constcacheKey=awaitcache.restoreCache(paths,key);if(cacheKey){core.info(`Cache restored from key: ${cacheKey}`);return;}// At this point the variable `paths = ["some/paths", "zstd-without-long", "1.0"]`constsavedCacheKey=awaitcache.saveCache(paths,key);// This means when `saveCache` calls `getCacheVersion` it was actually calculated off of the final array value: `["some/paths", "zstd-without-long", "1.0", "zstd-without-long", "1.0"]`}
This means that we run into a version mismatch when restoring the cache in another step later on.
Expected behavior
Inputs to functions don't get mutated and break intended functionality of the library.
Screenshots
This is following the hashing to create versions, with the inputs from our code, and you can see that components2 with the compression and version salt in twice matches the version of the created caches.
The text was updated successfully, but these errors were encountered:
Describe the bug
https://github.com/actions/toolkit/blob/main/packages/cache/src/internal/cacheHttpClient.ts#L83
This line means that the changes to the array change the array the user passes.
This breaks code such as
This means that we run into a version mismatch when restoring the cache in another step later on.
Expected behavior
Inputs to functions don't get mutated and break intended functionality of the library.
Screenshots
This is following the hashing to create versions, with the inputs from our code, and you can see that
components2
with the compression and version salt in twice matches the version of the created caches.The text was updated successfully, but these errors were encountered: