cache icon indicating copy to clipboard operation
cache copied to clipboard

Documentation is unclear about `cache-hit`'s value when the cache misses.

Open lima-limon-inc opened this issue 1 year ago • 1 comments

In some places it is stated that cache-hit evaluates to the empty string when if fails, notably here:

  • https://github.com/actions/cache/blob/main/README.md?plain=1#L86-L88
  • Also here: https://github.com/actions/cache/issues/1466#issuecomment-2400480945 (I found this issue reading the code, more specifically here: https://github.com/actions/cache/blob/1bd1e32a3bdc45362d1e726936510720a7c30a57/src/restoreImpl.ts#L54-L55

However this would appear to contradict this other statement:

  • https://github.com/actions/cache/blob/main/README.md?plain=1#L129

I am assuming that the latter is a mistake and the former is the intended behavior (mainly based on the comments of the issue linked above). Is this assumption correct or am I missing something?

Is there any specific moment in the codebase where the empty string is returned? I was not able to find it. Do note that I am not too familiar with typescript. AFAIK, it would seem that the only places where cache-hit is set are:

  • https://github.com/actions/cache/blob/1bd1e32a3bdc45362d1e726936510720a7c30a57/src/restoreImpl.ts#L18
    • Here it is set to false
  • https://github.com/actions/cache/blob/1bd1e32a3bdc45362d1e726936510720a7c30a57/src/restoreImpl.ts#L79
    • And here, the isExactKeyMatch appears to return a boolean (based on its signature https://github.com/actions/cache/blob/main/src/utils/actionUtils.ts#L19).

Furthermore, are there any examples in how to handle the case when the cacheHit evaluates to the empty string? I could only find examples where that variable is tested for "true" or "false".

Thanks in advance!

lima-limon-inc avatar Dec 11 '24 12:12 lima-limon-inc

Btw, I have opened a PR to update the documentation to reflect this behavior: #1514

lima-limon-inc avatar Apr 16 '25 14:04 lima-limon-inc