Skip to content

Commit 46b0087

Browse files
betterproto: avoid assigning a var of type Optional[InclusionPromise] to TransparencyLogEntry.inclusion_promise
``` File "/usr/local/google/home/rpetgrave/src/ssp/sigstore-python/sigstore/models.py", line 262, in _to_rekor tlog_entry = rekor_v1.TransparencyLogEntry( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/google/home/rpetgrave/src/ssp/.venv/lib/python3.12/site-packages/pydantic/_internal/_dataclasses.py", line 120, in __init__ s.__pydantic_validator__.validate_python(ArgsKwargs(args, kwargs), self_instance=s) pydantic_core._pydantic_core.ValidationError: 1 validation error for TransparencyLogEntry inclusion_promise Input should be a dictionary or an instance of InclusionPromise [type=dataclass_type, input_value=None, input_type=NoneType] ``` Signed-off-by: Ramon Petgrave <[email protected]>
1 parent baa95ac commit 46b0087

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ All versions prior to 0.9.0 are untracked.
1010

1111
### Fixed
1212

13+
* Avoid pydantic's instantiation issues with `TransparencyLogEntry` when `InclusionPromise` is not present.
14+
1315
* TSA: Changed the Timestamp Authority requests to explicitly use sha256 for message digests.
1416
[#1373](https://github.com/sigstore/sigstore-python/pull/1373)
1517

sigstore/models.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -239,12 +239,6 @@ def _to_rekor(self) -> rekor_v1.TransparencyLogEntry:
239239
240240
@private
241241
"""
242-
inclusion_promise: rekor_v1.InclusionPromise | None = None
243-
if self.inclusion_promise:
244-
inclusion_promise = rekor_v1.InclusionPromise(
245-
signed_entry_timestamp=base64.b64decode(self.inclusion_promise)
246-
)
247-
248242
inclusion_proof = rekor_v1.InclusionProof(
249243
log_index=self.inclusion_proof.log_index,
250244
root_hash=bytes.fromhex(self.inclusion_proof.root_hash),
@@ -257,10 +251,14 @@ def _to_rekor(self) -> rekor_v1.TransparencyLogEntry:
257251
log_index=self.log_index,
258252
log_id=common_v1.LogId(key_id=bytes.fromhex(self.log_id)),
259253
integrated_time=self.integrated_time,
260-
inclusion_promise=inclusion_promise, # type: ignore[arg-type]
261254
inclusion_proof=inclusion_proof,
262255
canonicalized_body=base64.b64decode(self.body),
263256
)
257+
if self.inclusion_promise:
258+
inclusion_promise = rekor_v1.InclusionPromise(
259+
signed_entry_timestamp=base64.b64decode(self.inclusion_promise)
260+
)
261+
tlog_entry.inclusion_promise = inclusion_promise
264262

265263
# Fill in the appropriate kind
266264
body_entry: ProposedEntry = TypeAdapter(ProposedEntry).validate_json(

0 commit comments

Comments
 (0)