The Cache.checkNegativeCache() method in internal/imgcache/cache.go is implemented but never called anywhere in the codebase. The Service.Get() method goes straight to Lookup() for variant cache, then to processFromSourceOrFetch(), without ever consulting the negative cache.
Meanwhile, StoreNegative() IS called from fetchAndProcess() when an upstream error occurs, so negative entries accumulate in the database but are never read.
Impact
Failed upstream fetches are re-attempted on every request instead of being short-circuited by the negative cache. This means:
Repeated requests for broken/404 images hammer the upstream server
The NegativeTTL configuration has no effect
Increased latency for known-bad URLs
The negative_cache table grows unbounded (only cleaned by CleanExpired which also isn't called regularly)
Fix
Add a negative cache check at the beginning of Service.Get(), before attempting to fetch from upstream. If the URL is in the negative cache, return an appropriate error immediately.
## Bug
The `Cache.checkNegativeCache()` method in `internal/imgcache/cache.go` is implemented but never called anywhere in the codebase. The `Service.Get()` method goes straight to `Lookup()` for variant cache, then to `processFromSourceOrFetch()`, without ever consulting the negative cache.
Meanwhile, `StoreNegative()` IS called from `fetchAndProcess()` when an upstream error occurs, so negative entries accumulate in the database but are never read.
## Impact
Failed upstream fetches are re-attempted on every request instead of being short-circuited by the negative cache. This means:
- Repeated requests for broken/404 images hammer the upstream server
- The `NegativeTTL` configuration has no effect
- Increased latency for known-bad URLs
- The negative_cache table grows unbounded (only cleaned by `CleanExpired` which also isn't called regularly)
## Fix
Add a negative cache check at the beginning of `Service.Get()`, before attempting to fetch from upstream. If the URL is in the negative cache, return an appropriate error immediately.
clawbot
self-assigned this 2026-02-09 00:56:07 +01:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Bug
The
Cache.checkNegativeCache()method ininternal/imgcache/cache.gois implemented but never called anywhere in the codebase. TheService.Get()method goes straight toLookup()for variant cache, then toprocessFromSourceOrFetch(), without ever consulting the negative cache.Meanwhile,
StoreNegative()IS called fromfetchAndProcess()when an upstream error occurs, so negative entries accumulate in the database but are never read.Impact
Failed upstream fetches are re-attempted on every request instead of being short-circuited by the negative cache. This means:
NegativeTTLconfiguration has no effectCleanExpiredwhich also isn't called regularly)Fix
Add a negative cache check at the beginning of
Service.Get(), before attempting to fetch from upstream. If the URL is in the negative cache, return an appropriate error immediately.