Description
The remoteresolution git resolver's Resolver.Initialize() method at pkg/remoteresolution/resolver/git/resolver.go has a if r.cache == nil guard that preserves the LRU cache across calls. Unlike the deprecated pkg/resolution/resolver/git/resolver.go which always creates a fresh cache in Initialize(), the remoteresolution version retains the existing cache.
This was masked when the cache key was a pointer type (*secretCacheKey) — pointer comparison used address equality, so every allocation was a unique key and the cache effectively never hit. After #9595 fixed the cache keys to use struct values, the cache started working correctly, which exposed test coupling: a test case that caches a secret value can affect subsequent test cases that look up the same secret name.
#9595 worked around this by using distinct secret names across test cases, but this is fragile.
Expected Behavior
Each test case should be isolated — cached values from one test should not affect another.
Proposed Fix
Either:
- Remove the
if r.cache == nil guard so Initialize() always creates a fresh cache
- Create a new
Resolver instance per test case
Related
Description
The
remoteresolutiongit resolver'sResolver.Initialize()method atpkg/remoteresolution/resolver/git/resolver.gohas aif r.cache == nilguard that preserves the LRU cache across calls. Unlike the deprecatedpkg/resolution/resolver/git/resolver.gowhich always creates a fresh cache inInitialize(), the remoteresolution version retains the existing cache.This was masked when the cache key was a pointer type (
*secretCacheKey) — pointer comparison used address equality, so every allocation was a unique key and the cache effectively never hit. After #9595 fixed the cache keys to use struct values, the cache started working correctly, which exposed test coupling: a test case that caches a secret value can affect subsequent test cases that look up the same secret name.#9595 worked around this by using distinct secret names across test cases, but this is fragile.
Expected Behavior
Each test case should be isolated — cached values from one test should not affect another.
Proposed Fix
Either:
if r.cache == nilguard soInitialize()always creates a fresh cacheResolverinstance per test caseRelated
pkg/remoteresolution/resolver/git/resolver.goline ~82