Skip to content

cache-hit undefined on cache miss? #1334

Closed

Description

@aryairani

The README says:

Note cache-hit will only be set to true when a cache hit occurs for the exact key match. For a partial key match via restore-keys or a cache miss, it will be set to false.

but outputs.cache-hit == 'false' doesn't seem to be true when I get a cache miss, and I noticed that the examples all use != 'true', not == 'false'.

I think here we can see restoreImpl return early on a miss, without setting any value for cache-hit at all. I'm not a TypeScript or Actions expert though.

In the meantime, I'll switch my == 'false' to != 'true' but I feel dirty. :)

Activity

  1. pddg commented on Apr 16, 2024

    @pddg

    This problem does not seem to occur in v3, only in v4. In fact, the repositories that had been delayed updating to v4 were working fine.
    In workflows that saving the cache when outputs.cache-hit == 'false', the cache was no longer being saved. I recognized this too late because it simply skips a step and does not result in an error.
    Is this a bug? Or is it a breaking change?

  2. RalfJung commented on May 3, 2024

    @RalfJung
  3. aryairani commented on May 3, 2024

    @aryairani
    Author

    @RalfJung: I was going to say don't use if: ${{ steps.cache.outputs.cache-hit != 'true' }} because that's a string that will always evaluate to true, not a boolean expression, and that you should use if: steps.cache.outputs.cache-hit != 'true' instead.

    But if it eventually worked for you, then I have no idea how anything works.

  4. no-yan commented on May 4, 2024

    @no-yan

    It looks like there are document revisions in progress related to this issue.
    #1263

  5. joshmgross commented on Oct 8, 2024

    @joshmgross
    Contributor

    This is being reverted in #1467 as workflows are already dependent on cache-hit being undefined - #1466

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions