Bug 2457600 - ansible-lint crashes with KeyError: 'ansible-core' — %prep sed patch incorrectly strips ansible-core from pyproject.toml
Summary: ansible-lint crashes with KeyError: 'ansible-core' — %prep sed patch incorrec...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: ansible-lint
Version: 44
Hardware: x86_64
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: Parag Nemade
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2026-04-11 20:26 UTC by herwig.koeck
Modified: 2026-05-07 00:52 UTC (History)
6 users (show)

Fixed In Version: ansible-lint-26.4.0-2.fc44
Clone Of:
Environment:
Last Closed: 2026-05-07 00:52:26 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description herwig.koeck 2026-04-11 20:26:33 UTC
Details:
ansible-lint fails immediately on Fedora 44 due to a stale patch in the RPM spec file. The %prep section contains:


# Fedora's ansible-core is 2.18.9 version currently
sed -i '37d' pyproject.toml
This deletes the ansible-core>=2.16.14 line from pyproject.toml before building, causing ansible-core to be absent from Requires-Dist in the installed dist-info METADATA.

The patch was originally introduced in 25.9.1-2 to work around Fedora's ansible-core 2.18.9 not satisfying the >=2.20.0b1 pre-release requirement. It was carried forward unchanged into 26.1.1, where the upstream requirement dropped to >=2.16.14 — which Fedora's 2.18.9 does satisfy. The sed is now incorrect and strips a valid, satisfiable dependency.

At runtime, ansible-lint's startup code calls Reqs("ansible-lint") to load the package's declared requirements, then checks whether the installed ansible-core satisfies them. Reqs.matches() returns False for any package absent from the requirements dict, triggering the error-handler branch. That branch then indexes self.reqs["ansible-core"] — which raises KeyError: 'ansible-core' and crashes before any linting occurs.

Reproducible: Always

Steps to Reproduce:
Install Fedora 44 (fresh install, x86_64)
sudo dnf install python3-ansible-lint
Run ansible-lint in any director
Actual Results:
Traceback (most recent call last):
  File "/usr/bin/ansible-lint", line 7, in <module>
    sys.exit(_run_cli_entrypoint())
  File ".../ansiblelint/__main__.py", line 376, in main
    app = get_app(offline=None, cached=True)
  File ".../ansiblelint/app.py", line 62, in __init__
    msg = f"ansible-lint requires {package}..."
KeyError: 'ansible-core'


Expected Results:
ansible-lint runs without crashing.



Additional Information:
Package: python3-ansible-lint-26.1.1-1.fc44 (built 2026-01-23)
Upstream PyPI 26.1.1 wheel correctly includes Requires-Dist: ansible-core>=2.16.14 — the bug is Fedora-packaging-specific
Installed Fedora METADATA verified: grep Requires-Dist /usr/lib/python3.14/site-packages/ansible_lint-*.dist-info/METADATA shows no ansible-core entry
ansible-core 2.20.3 is installed and functional; the crash is purely a metadata mismatch
Fix: Remove the sed -i '37d' pyproject.toml line from %prep in the spec file
Secondary hardening fix in upstream ansiblelint/app.py line 58: change if not self.reqs.matches(...) to if package in self.reqs and not self.reqs.matches(...) to prevent a crash if the metadata is ever missing again

Workaround (confirmed working):
sudo sed -i 's/        if not self.reqs.matches(/        if package in self.reqs and not self.reqs.matches(/' \
  /usr/lib/python3.14/site-packages/ansiblelint/app.py

Comment 1 Fedora Update System 2026-05-01 03:12:05 UTC
FEDORA-2026-7e39a8ce5a (ansible-lint-26.4.0-2.fc44 and python-ansible-compat-26.3.0-1.fc44) has been submitted as an update to Fedora 44.
https://bodhi.fedoraproject.org/updates/FEDORA-2026-7e39a8ce5a

Comment 2 Fedora Update System 2026-05-02 02:58:52 UTC
FEDORA-2026-7e39a8ce5a has been pushed to the Fedora 44 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2026-7e39a8ce5a`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2026-7e39a8ce5a

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 3 Fedora Update System 2026-05-07 00:52:26 UTC
FEDORA-2026-7e39a8ce5a (ansible-lint-26.4.0-2.fc44 and python-ansible-compat-26.3.0-1.fc44) has been pushed to the Fedora 44 stable repository.
If problem still persists, please make note of it in this bug report.


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