Skip to content

Pydentic scheme for CacheConfiguration and RouteInfo#7

Merged
chud0 merged 8 commits into
mainfrom
feature/cache-scheme
Jun 30, 2025
Merged

Pydentic scheme for CacheConfiguration and RouteInfo#7
chud0 merged 8 commits into
mainfrom
feature/cache-scheme

Conversation

@chud0
Copy link
Copy Markdown
Owner

@chud0 chud0 commented Jun 25, 2025

No description provided.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

@chud0 chud0 merged commit 6004762 into main Jun 30, 2025
4 checks passed
@chud0 chud0 deleted the feature/cache-scheme branch June 30, 2025 20:23
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Cache Configuration Validator Returns Inconsistent Types

The CacheConfiguration.invalidate_paths field validator (compile_paths) has inconsistent return types, violating its list[re.Pattern] | None annotation. It returns a single re.Pattern object for string or single pattern inputs, and can produce nested lists (e.g., list[list[re.Pattern]]) for nested list inputs. This type mismatch causes runtime errors when consuming code expects to iterate over a flat list of patterns.

fast_cache_middleware/schemas.py#L45-L59

@field_validator("invalidate_paths")
@classmethod
def compile_paths(cls, item: Any) -> Any:
if item is None:
return None
if isinstance(item, str):
return re.compile(f"^{item}")
if isinstance(item, re.Pattern):
return item
if isinstance(item, list):
return [cls.compile_paths(i) for i in item]
raise ValueError(
"invalidate_paths must be a string, regex pattern, or list of them."
)

Fix in Cursor


Bug: Zero TTL Incorrectly Disables Caching

The condition if not cache_configuration.max_age: incorrectly disables caching when max_age is 0. This changes the previous behavior where max_age=0 was a valid TTL for immediate expiration. Caching should only be disabled when max_age is None.

fast_cache_middleware/middleware.py#L257-L259

if not cache_configuration.max_age:
return None

Fix in Cursor


Was this report helpful? Give feedback by reacting with 👍 or 👎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant