Skip to content

Commit

Permalink
Fix a serialization issue
Browse files Browse the repository at this point in the history
Our data model allows null sum_types, but createrepo_c types don't
allow setting such values. It defaults to a value of 0, or "unknown"

Let's only print a checksum if we have a sensible value for both sum and
sum_type.

[noissue]
  • Loading branch information
dralley committed Jan 30, 2024
1 parent 07ddb43 commit df65dad
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pulp_rpm/app/models/advisory.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,10 @@ def to_createrepo_c(self):
pkg.relogin_suggested = self.relogin_suggested
if self.restart_suggested:
pkg.restart_suggested = self.restart_suggested
if self.sum:
if self.sum and self.sum_type:
# Whether self.sum is None controls whether or not the <sum> tag will be serialized
# If self.sum_type is 0 the result will be createrepo_c printing "Unknown checksum",
# an invalid value, thus we don't want to set self.sum if this will happen.
pkg.sum = self.sum
pkg.sum_type = self.sum_type

Expand Down

0 comments on commit df65dad

Please sign in to comment.