RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1913418 - dnf API glob filter does not support brace expansion
Summary: dnf API glob filter does not support brace expansion
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: dnf
Version: 8.3
Hardware: Unspecified
OS: Unspecified
low
unspecified
Target Milestone: rc
: 8.0
Assignee: Lukáš Hrázký
QA Contact: Eva Mrakova
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2021-01-06 18:08 UTC by Michal Bocek
Modified: 2021-05-18 15:01 UTC (History)
3 users (show)

Fixed In Version: dnf-4.4.2-5.el8
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2021-05-18 15:01:28 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Michal Bocek 2021-01-06 18:08:11 UTC
Description of problem:
Using curly braces shell-style expansion does not work when using dnf.query.Query.filter (https://dnf.readthedocs.io/en/latest/api_queries.html#dnf.query.Query.filter) with glob keyname.

The documentation linked above says that using glob with the filter means "shell-style wildcard match".
And the dnf man page says in the Globs section "{} Matches any of the comma separated list of enclosed strings."

Version-Release number of selected component (if applicable):
dnf-0:4.2.23-4.el8.noarch
rpm-0:4.14.3-4.el8.x86_64

Steps to Reproduce:
1. Open python3 interpreter on RHEL 8.3
2. Run the following code
```
import dnf
dnf_base = dnf.Base()
dnf_base.fill_sack(load_system_repo=True, load_available_repos=False)
query = dnf_base.sack.query()
installed = query.installed()
installed = installed.filter(name__glob="redhat-{,linux-}release")
if list(installed):
  print(list(installed)[0].name)
else:
  print("Not found")
```

Actual results:
"Not found" is printed. The curly braces are not expanded.

Expected results:
I expect to see "redhat-release".

Additional info:
Running `dnf info redhat-{,linux-}release` gives me info about redhat-release, so the expansion works this way.
Using "*" in the filter works, so if I search for "redhat-*release", it is found.

Comment 2 Lukáš Hrázký 2021-01-11 15:54:15 UTC
Allright, this is interesting, I got got by this as well.

We are using the fnmatch() call to match the globs and fnmatch doesn't support curly brackets, it is an extension in bash and possibly other shells. The reason e.g. `dnf info redhat-{,linux-}release` works is because it's actually bash doing the expansion for you.

I've fixed the documentation: https://github.com/rpm-software-management/dnf/pull/1710

We aren't planning on implementing our own fnmach to support curly brackets.

Comment 3 Michal Bocek 2021-01-11 16:04:56 UTC
Ok. Thanks, Lukas, for looking into it.

Comment 11 errata-xmlrpc 2021-05-18 15:01:28 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (dnf bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2021:1657


Note You need to log in before you can comment on or make changes to this bug.