Bug 1299261

Summary: dnf repoquery's --repo argument does not work
Product: [Fedora] Fedora Reporter: Erik Johnson <erik>
Component: dnf-plugins-coreAssignee: Packaging Maintenance Team <packaging-team-maint>
Status: CLOSED DUPLICATE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 22CC: jsilhan, mluscon, packaging-team-maint, pnemade, RadekHolyPublic, vmukhame
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-01-19 15:10:52 UTC 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:

Description Erik Johnson 2016-01-17 23:22:43 UTC
Description of problem:

The release notes for 0.1.7 state that --repoid has been changed to --repo to make usage consistent (http://dnf-plugins-core.readthedocs.org/en/latest/release_notes.html?#id8)

However, using "--repo" results in an error while using the old (and now deprecated) "--repoid" works properly.


Version-Release number of selected component (if applicable):

At least the most recent version (as of now, 0.1.15) has this problem.


How reproducible:

100% of the time


Steps to Reproduce:

1. Run the following command:

dnf repoquery --quiet --repo=updates --queryformat='%{name} - %{repoid}' bash


Actual results:

usage: dnf [--allowerasing] [-b] [-C] [-c [config file]] [-d [debug level]]
           [--debugsolver] [--showduplicates] [-e ERRORLEVEL]
           [--rpmverbosity [debug level name]] [-q] [-v] [-y] [--assumeno]
           [--version] [--installroot [path]] [--enablerepo [repo]]
           [--disablerepo [repo]] [-x [package]] [--disableexcludes [repo]]
           [--repofrompath [repo,path]] [--noplugins] [--nogpgcheck]
           [--disableplugin [plugin]] [--color COLOR]
           [--releasever RELEASEVER] [--setopt SETOPTS] [--refresh] [-4] [-6]
           [--downloadonly] [-h]
Command line error: argument --repofrompath: bad format: updates


Expected results:

bash - updates


Additional info:

As mentioned above, using --repoid works properly:

% dnf repoquery --quiet --repoid=updates --queryformat='%{name} - %{repoid}' bash
bash - updates

Comment 1 Erik Johnson 2016-01-18 01:34:56 UTC
I've found the issue. This is getting caught up in dnf's own argument parsing before it ever reaches the repoquery plugin. I dug into the source code for argparse in the Python stdlib, and found this gem:

for option_string in self._option_string_actions:
    if option_string.startswith(option_prefix):
        action = self._option_string_actions[option_string]
        tup = action, option_string, explicit_arg
        result.append(tup)

(See https://hg.python.org/releases/2.7.11/file/tip/Lib/argparse.py#l2156)

So, what's happening is that the repoquery plugin has a "--repo" argument, but because of this loose matching in argparse.py, it is being matched to "--repofrompat" from dnf proper.

Comment 2 Honza Silhan 2016-01-19 15:10:52 UTC

*** This bug has been marked as a duplicate of bug 1260986 ***