Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
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

Summary: dnf API glob filter does not support brace expansion
Product: Red Hat Enterprise Linux 8 Reporter: Michal Bocek <mbocek>
Component: dnfAssignee: Lukáš Hrázký <lhrazky>
Status: CLOSED ERRATA QA Contact: Eva Mrakova <emrakova>
Severity: unspecified Docs Contact:
Priority: low    
Version: 8.3CC: james.antill, lhrazky, nsella
Target Milestone: rcKeywords: FutureFeature, Triaged
Target Release: 8.0Flags: pm-rhel: mirror+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: dnf-4.4.2-5.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-05-18 15:01:28 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 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