Skip to content

Commit

Permalink
Allow string integers in modulemd version
Browse files Browse the repository at this point in the history
Trivial fix, allows modulemd version data to be of type string if that
string represents a valid integer, matching very basic regex.
closes pulp#2998
  • Loading branch information
Alex-Welsh committed Mar 15, 2023
1 parent 7421255 commit 45734bc
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES/2998.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Loosen modulemd validation to allow version numbers that have string type but represent integers
5 changes: 5 additions & 0 deletions pulp_rpm/app/modulemd.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,11 @@ def parse_modular(file):
# are not enough then we only need to take required data from dict which is
# parsed by pyyaml library
if parsed_data["document"] == "modulemd":
# the validator currently accepts formatting slightly different to the
# spec due to the misconfiguration of some Rocky Linux 9 repositories
# https://bugs.rockylinux.org/view.php?id=2575
# further discussion on this issue can be found here:
# https://github.com/pulp/pulp_rpm/issues/2998
validator = Draft7Validator(MODULEMD_SCHEMA)
err = []
for error in sorted(validator.iter_errors(parsed_data["data"]), key=str):
Expand Down
5 changes: 4 additions & 1 deletion pulp_rpm/app/schema/modulemd.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
"type": "object",
"properties": {
"name": {"type": "string"},
"version": {"type": "integer"},
"version": {
"type": ["integer", "string"],
"pattern": "^[0-9]+$"
},
"context": {"type": ["number", "string"]},
"arch": {"type": "string"},
"summary": {"type": "string"},
Expand Down

0 comments on commit 45734bc

Please sign in to comment.