This is an automated email from the ASF dual-hosted git repository.

sbp pushed a commit to branch sbp
in repository https://gitbox.apache.org/repos/asf/tooling-trusted-releases.git


The following commit(s) were added to refs/heads/sbp by this push:
     new 72337633 Tolerate malformed NULL values in selected attestable policy 
fields
72337633 is described below

commit 723376339768e44094de82e853e53a2288ac012c
Author: Sean B. Palmer <[email protected]>
AuthorDate: Thu Mar 12 16:11:53 2026 +0000

    Tolerate malformed NULL values in selected attestable policy fields
---
 atr/tasks/checks/__init__.py | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/atr/tasks/checks/__init__.py b/atr/tasks/checks/__init__.py
index c223f83d..bb40eb4a 100644
--- a/atr/tasks/checks/__init__.py
+++ b/atr/tasks/checks/__init__.py
@@ -346,7 +346,8 @@ async def resolve_cache_key(
     file_hash = None
     attestable_data = await attestable.load(release.safe_project_name, 
release.safe_version_name, revision)
     if attestable_data:
-        policy = sql.ReleasePolicy.model_validate(attestable_data.policy)
+        policy_dict = _coerce_policy_nulls(attestable_data.policy)
+        policy = sql.ReleasePolicy.model_validate(policy_dict)
         if not ignore_path:
             file_hash = attestable_data.paths.get(file) if file else None
     else:
@@ -396,6 +397,19 @@ def with_model(cls: type[schema.Strict]) -> 
Callable[[Callable[..., Any]], Calla
     return decorator
 
 
+def _coerce_policy_nulls(policy: dict[str, Any]) -> dict[str, Any]:
+    # This is a shim for a bug in the models persisted in attestable data
+    # The bug is linted by scripts/check_nullable_fields.py
+    result = dict(policy)
+    for key, value in result.items():
+        if (value is not None) or (key not in sql.ReleasePolicy.model_fields):
+            continue
+        field = sql.ReleasePolicy.model_fields[key]
+        if (field.default_factory is not None) and (field.default_factory is 
list):
+            result[key] = []
+    return result
+
+
 async def _resolve_all_files(release: sql.Release, rel_path: str | None = 
None) -> list[str]:
     if not release.latest_revision_number:
         return []


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to