Bug 2186223

Summary: repo2module fails when source RPMs are present in the repository
Product: Red Hat Enterprise Linux 8 Reporter: Stepan Broz <sbroz>
Component: modulemd-toolsAssignee: Jakub Kadlčík <jkadlcik>
Status: VERIFIED --- QA Contact: Tomáš Bajer <tbajer>
Severity: medium Docs Contact:
Priority: medium    
Version: 8.7CC: ovasik, tbajer
Target Milestone: rcKeywords: Triaged
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: modulemd-tools-0.7-8.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 2227436 (view as bug list) Environment:
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 2227436    

Description Stepan Broz 2023-04-12 13:08:17 UTC
Description of problem:
The "repo2module" utility fails everytime a (modular) .src.rpm is present in the repository.

Version-Release number of selected component (if applicable):
libmodulemd-2.13.0-1.el8.x86_64
modulemd-tools-0.7-6.el8.noarch
python3-libmodulemd-2.13.0-1.el8.x86_64

How reproducible:
Always

Steps to Reproduce:
1. Create a test directory for the repo:
    # mkdir /root/repotest; cd /root/repotest

2. Download any modular .src.rpm, e.g. from brew or the Customer Portal.
    # curl "https://access.cdn.redhat.com/content/origin/rpms/aardvark-dns/1.1.0/5.module+el8.7.0+17824+66a0202b/fd431d51/aardvark-dns-1.1.0-5.module+el8.7.0+17824+66a0202b.src.rpm?user=90e4f6b5af3546dc2d63e878c977a13c&_auth_=1681318997_fcd05a5aa4cf0b47ae935f1995ed379e" -o aardvark-dns-1.1.0-5.module+el8.7.0+17824+66a0202b.src.rpm
   
3. Create non-modular repo:
    # createrepo /root/repotest

4. Run repo2module:
    # repo2module . --module-name foo --module-stream devel --module-version 123 --module-context f00d

Actual results:
Traceback (most recent call last):
  File "/usr/bin/repo2module", line 11, in <module>
    load_entry_point('repo2module==0.1', 'console_scripts', 'repo2module')()
  File "/usr/lib/python3.6/site-packages/repo2module/cli.py", line 122, in cli
    source_packages = get_source_packages(packages)
  File "/usr/lib/python3.6/site-packages/repo2module/cli.py", line 65, in get_source_packages
    subject = Subject(pkg.rpm_sourcerpm[:-4])
TypeError: 'NoneType' object is not subscriptable

Expected results:
Modular repo created or a self-explanatory error presented to the user.

Additional info:

Comment 1 Jakub Kadlčík 2023-04-26 14:45:13 UTC
Hello Stepan,
thank you for the report.

Unfortunately, the link from step 2 doesn't work anymore - "Download links are dynamic and available for 240 minutes before they expire". But I tried to download some modular package from brew and it seems to work for me with the upstream version of modulemd-version:

    $ cp ~/Downloads/aardvark-dns-1.5.0-2.module+el8.8.0+18060+3f21f2cc.x86_64.rpm .

    $ createrepo .
    Directory walk started
    Directory walk done - 1 packages
    Temporary output repo path: ./.repodata/
    Preparing sqlite DBs
    Pool started (with 5 workers)
    Pool finished

    $ repo2module . --module-name foo --module-stream devel --module-version 123 --module-context f00d

    $ cat modules.yaml |grep artifacts: -A2
      artifacts:
        rpms:
        - aardvark-dns-2:1.5.0-2.module+el8.8.0+18060+3f21f2cc.x86_64

There is an unnecessarily old version of modulemd-tools in RHEL8. Maybe we can update it to modulemd-tools-0.13 which is in Fedora?

Comment 2 Stepan Broz 2023-04-26 15:25:11 UTC
The link is irrelevant, any modular SRC RPM can be used to trigger the error -- note the SRC RPM (SRPM). It works fine with binary RPMs (e.g. "aardvark-dns-1.5.0-2.module+el8.8.0+18060+3f21f2cc.x86_64.rpm").

I am not sure what you meant by the old version of modulemd-tools in RHEL-8. That's what's shipped and what we have reported the issue on.

Do you believe the issue itself is not manifesting itself with modulemd-tools-0.13? If so, do you plan a rebase in the next RHEL-8 minor?

Comment 3 Jakub Kadlčík 2023-05-01 22:11:37 UTC
Hello Stepan,

> note the SRC RPM (SRPM)

Sorry about that, I missed this important part when reproducing the issue.
It turns out that this issue happens even with the latest upstream version of modulemd-tools, so I am currently working on a fix.

Comment 4 Jakub Kadlčík 2023-05-01 22:21:51 UTC
I am proposing the following patch
https://github.com/rpm-software-management/modulemd-tools/pull/66