You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The _get_blob_by_metadata_version method in policyengine/utils/data/version_aware_storage_client.py returns the first blob that matches the requested version instead of the newest one.
Current Behavior
When multiple blobs exist with the same metadata version (which can happen when a blob is re-uploaded with the same version tag), the function iterates through bucket.list_blobs() and returns the first match:
forblobinversions:
ifblob.metadataandblob.metadata.get("version") ==version:
returnblob# BUG: Returns FIRST match (oldest), not newest!
This results in returning the oldest blob instead of the newest one.
Expected Behavior
The function should return the blob with the highest generation number (the newest blob) when multiple blobs match the requested version.
Proposed Fix
Collect all matching blobs and return the one with the highest generation number:
matching_blobs= []
forblobinversions:
ifblob.metadataandblob.metadata.get("version") ==version:
matching_blobs.append(blob)
ifnotmatching_blobs:
raiseValueError(...)
# Return the blob with the highest generation number (newest)newest_blob=max(matching_blobs, key=lambdab: b.generation)
returnnewest_blob
Impact
Users requesting a specific version may receive stale data if the blob was re-uploaded with the same version tag.
Activity
anth-volk commentedon Feb 6, 2026
Fixed by #219