#23223·prefect

Subtracting an input from a configured cache policy drops key_storage / isolation_level / lock_manager

Author: MohammadHijjawi97Created Sep 28, 2026Updated Sep 28, 2026
Labelsbug

Bug summary

Inputs.__sub__ and CompoundCachePolicy.__sub__ construct a brand-new policy (Inputs(exclude=...) / CompoundCachePolicy(policies=...)) without carrying over the settings from .configure(), so excluding an input drops key_storage, isolation_level and lock_manager:

python
from prefect.cache_policies import INPUTS, DEFAULT
p = INPUTS.configure(key_storage="/tmp/keys", isolation_level="SERIALIZABLE") - "x"
print(p.key_storage, p.isolation_level)  # None None
q = DEFAULT.configure(key_storage="/tmp/keys", isolation_level="SERIALIZABLE") - "x"
print(q.key_storage, q.isolation_level)  # None None

Expected: the configuration is preserved, as it already is for +.

Impact: a task using e.g. INPUTS.configure(isolation_level="SERIALIZABLE", lock_manager=MemoryLockManager()) - "client" silently runs without locking, and a custom key_storage is ignored (cache records go to the default location).

Version info

main @ 4f52bc6

Additional context

A fix is to build the result with dataclasses.replace(self, ...) in both __sub__ methods; I'm opening a PR with that and regression tests.