Problem/Motivation
After updating from Drupal 10.3 to 10.4 this error emerged:
User warning: Trying to overwrite a cache redirect with one that has nothing in common, old one at address "languages:language_interface, theme, user.permissions" was pointing to "url.path.parent, url.path.is_front, route", new one points to "url.path, languages:language_url". in Drupal\Core\Cache\VariationCache->set() (line 138 of core/lib/Drupal/Core/Cache/VariationCache.php).
Steps to reproduce
No other actions beyond the update.
Proposed resolution
Apparently the cache context in the BreadcrumbBuilder needs to be enhanced. At least this appears to solve the problem in my case.
In BreadcrumbBuilder.php line 227 this row
$breadcrumb->addCacheContexts(['url.path']);
needs to be replaced by this:
$breadcrumb->addCacheContexts([
'url.path',
'languages:language_url',
'languages:language_interface',
'theme',
'user.permissions',
'url.path.parent',
'url.path.is_front',
'route'
]);
Remaining tasks
Review suggestion and update the code.