MCPcopy Create free account
hub / github.com/github/gh-aw / validateNoCacheKeyRunID

Function validateNoCacheKeyRunID

pkg/workflow/cache_validation.go:38–48  ·  view source on GitHub ↗

validateNoCacheKeyRunID returns an error when a user-supplied cache key contains the ${{ github.run_id }} expression. Including run_id in the key means every run writes to a unique cache slot and the cache can never be restored from a previous run. The compiler already appends run_id automatically

(key string)

Source from the content-addressed store, hash-verified

36// appends run_id automatically to the save key while generating a stable
37// restore-keys prefix — users must not add it themselves.
38func validateNoCacheKeyRunID(key string) error {
39 if cacheKeyRunIDPattern.MatchString(key) {
40 return NewValidationError(
41 "tools.cache-memory.key",
42 key,
43 "cache key must not reference github.run_id — every run would write to a unique cache slot, preventing cross-run cache restoration",
44 "Remove github.run_id from the key. The compiler appends it automatically to the save key and generates a stable restore-keys prefix.\n\nExample:\n\ntools:\n cache-memory:\n key: my-data-${{ env.GH_AW_WORKFLOW_ID_SANITIZED }}\n # ✓ compiler adds run_id to the save key; restore-keys prefix enables cross-run restoration",
45 )
46 }
47 return nil
48}
49
50// validateNoDuplicateCacheIDs checks for duplicate cache IDs and returns an error if found.
51// Uses the generic validateNoDuplicateIDs helper for consistent duplicate detection.

Callers 1

parseCacheMemoryIdentityFunction · 0.85

Calls 1

NewValidationErrorFunction · 0.70

Tested by

no test coverage detected