sentry-symfony icon indicating copy to clipboard operation
sentry-symfony copied to clipboard

Sentry cannot deal with sub namespaced NamespacedPoolInterface caches

Open Coffee2CodeNL opened this issue 1 month ago • 4 comments

How do you use Sentry?

Sentry SaaS (sentry.io)

SDK version

4.18.1

Bundle Version

5.6.0

Steps to reproduce

  1. Inject cache like so
    /** @var CacheInterface&NamespacedPoolInterface&TagAwareCacheInterface */
    private readonly CacheInterface $cache;

    /**
     * @param CacheInterface&NamespacedPoolInterface&TagAwareCacheInterface $cache
     *
     * @throws InvalidArgumentException
     */
    public function __construct(
        #[Autowire(service: 'cache.custom_pool')]
        CacheInterface $cache,
    ) {
        $this->cache = $cache->withSubNameSpace(PriceFilter::class);
    }
  1. retrieve something from cache like so
        $this->cache->get('a_cache_key', function (ItemInterface $item) {
            $item->tag(['a tag name']);

            return $this->getDataFromDatabase();
        });

Expected result

Not get an error when creating a subnamespaced cache

Actual result

Cannot call "Sentry\SentryBundle\Tracing\Cache\TraceableTagAwareCacheAdapterForV3::withSubNamespace()": this class doesn't implement "Symfony\Contracts\Cache\NamespacedPoolInterface".

Coffee2CodeNL avatar Nov 21 '25 03:11 Coffee2CodeNL

SYMFONY-32

linear[bot] avatar Nov 21 '25 03:11 linear[bot]

Hi @Coffee2CodeNL! Thanks for opening the issue!

Seems like this was added relatively recent (Mai 2025) so we haven't added support yet. Since this looks rather easy to add, I will aim to add it next week

Litarnus avatar Nov 21 '25 10:11 Litarnus

@Litarnus how is this coming along?

Coffee2CodeNL avatar Dec 08 '25 08:12 Coffee2CodeNL

We have https://github.com/getsentry/sentry-symfony/issues/973 open.

cleptric avatar Dec 11 '25 22:12 cleptric