Bug 2210694

Summary: Config error: Parsing file "/etc/dnf/dnf.conf" failed: Parsing file '/etc/dnf/dnf.conf' failed: IniParser: Missing section header at line 1
Product: [Fedora] Fedora Reporter: Jan Pazdziora <jpazdziora>
Component: dnfAssignee: Jan Kolarik <jkolarik>
Status: POST --- QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: high Docs Contact:
Priority: unspecified    
Version: 39CC: amatej, daniel.mach, jmracek, jpazdziora, jrohel, lslebodn, mblaha, mburket, packaging-team-maint, pkratoch, rmeggins, rpm-software-management, valdis.kletnieks
Target Milestone: ---Keywords: Regression, Triaged
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Jan Pazdziora 2023-05-29 07:23:42 UTC
In Fedora rawhide container, dnf started to fail with

Config error: Parsing file "/etc/dnf/dnf.conf" failed: Parsing file '/etc/dnf/dnf.conf' failed: IniParser: Missing section header at line 1

Reproducible: Always

Steps to Reproduce:
1. podman run --rm -ti registry.fedoraproject.org/fedora:rawhide dnf install zsh
Actual Results:  
Config error: Parsing file "/etc/dnf/dnf.conf" failed: Parsing file '/etc/dnf/dnf.conf' failed: IniParser: Missing section header at line 1

Expected Results:  
Fedora rawhide openh264 (From Cisco) - x86_64   2.5 kB/s | 2.5 kB     00:00    
Fedora - Rawhide - Developmental packages for t 7.7 MB/s |  71 MB     00:09    
Fedora - Modular Rawhide - Developmental packag 1.6 MB/s | 1.6 MB     00:00    
Dependencies resolved.
================================================================================
 Package       Architecture    Version                   Repository        Size
================================================================================
Installing:
 zsh           x86_64          5.9-5.fc38                rawhide          3.3 M
Installing dependencies:
 pcre          x86_64          8.45-1.fc38.3             rawhide          201 k

Transaction Summary
================================================================================
Install  2 Packages

Total download size: 3.5 M
Installed size: 8.5 M
Is this ok [y/N]: 

In older versions of the Fedora rawhide image, the /etc/dnf/dnf.conf content was

# see `man dnf.conf` for defaults and possible options

[main]
gpgcheck=True
installonly_limit=3
clean_requirements_on_remove=True
best=False
skip_if_unavailable=True
tsflags=nodocs

Now it is just

tsflags=nodocs

Comment 1 Jan Pazdziora 2023-05-29 07:27:23 UTC
In https://src.fedoraproject.org/rpms/dnf/c/e1d55d6da26f89662e3669d910aead08cde2a7e2?branch=rawhide I see Remove ownership of dnf.conf so the problem is caused by a change in the dnf component.

Even if the root cause is likely that the Fedora container image assumes that the file exists and just appends that tsflags line there, I believe it's the dnf maintainers that should set the assumptions and expected behaviour before landing a change that breaks the containerized use-cases.

Comment 2 Valdis Kletnieks 2023-05-30 05:01:32 UTC
(In reply to Jan Pazdziora from comment #1)
> In
> https://src.fedoraproject.org/rpms/dnf/c/
> e1d55d6da26f89662e3669d910aead08cde2a7e2?branch=rawhide I see Remove
> ownership of dnf.conf so the problem is caused by a change in the dnf
> component.
> 
> Even if the root cause is likely that the Fedora container image assumes
> that the file exists and just appends that tsflags line there, I believe
> it's the dnf maintainers that should set the assumptions and expected
> behaviour before landing a change that breaks the containerized use-cases.

That change makes dnf move /etc/dnf/dnf.conf to dnf.conf.rpmsave, so the next
run of dnf doesn't see any of the config variables that used to be there.
I spotted this bug report after I opened bug #2210931 against DNF.

Comment 3 amatej 2023-05-30 05:10:51 UTC
*** Bug 2210931 has been marked as a duplicate of this bug. ***

Comment 4 Jan Kolarik 2023-05-30 08:19:11 UTC
This is temporarily fixed by untagging the dnf packages introducing these changes from Rawhide. We will investigate the problem in the meanwhile. 

The default dnf.conf now should be like:
"""
# see `man dnf.conf` for defaults and possible options

[main]
"""

Comment 5 Jan Kolarik 2023-05-30 08:20:50 UTC
Sorry, I meant that is how default dnf.conf should look like after introducing the proposed changes...

Comment 6 Jan Kolarik 2023-06-01 14:19:44 UTC
Today I was testing two use cases with new dnf and dnf5 packages already in nightly copr repos.

Setup
-----
1. podman run --rm -ti registry.fedoraproject.org/fedora:rawhide sh
2. dnf install dnf-plugins-core
3. dnf copr enable rpmsoftwaremanagement/dnf-nightly

Usecase A - upgrade to newest dnf, then install newest dnf5
-----------------------------------------------------------
4. dnf upgrade dnf
# now /etc/dnf/dnf.conf doesn't exist as nobody owns it without the newest dnf5 package being present
# /etc/dnf/dnf.conf.rpmsave is created as the backup of the original config file
5. dnf copr enable rpmsoftwaremanagement/dnf5-unstable
6. dnf install dnf5
# now /etc/dnf/dnf.conf is created, containing the dnf5 defaults:

"""
# see `man dnf.conf` for defaults and possible options

[main]
"""

Usecase B - install newest dnf5, upgrade dnf, replace dnf in a single transaction
---------------------------------------------------------------------------------
4. dnf copr enable rpmsoftwaremanagement/dnf5-unstable
5. dnf install dnf5
# /etc/dnf/dnf.conf remains unchanged
# /etc/dnf/dnf.conf.rpmnew is the new empty config file delivered by the dnf5

So it seems, using the nightly copr repos, it is currently working as expected.

In Rawhide, we are now working with dependent components using the DNF CLI needed in the build environment to manage their transition to DNF5 CLI. After that is done and tested, we are planning to release new versions into the Rawhide.

Comment 7 Jan Kolarik 2023-06-01 14:22:34 UTC
I guess the original issue was caused by untagging the dnf5 package first, while the new dnf package remained in the Rawhide for some time.

Comment 8 Jan Kolarik 2023-06-05 06:32:46 UTC
I apologize for not realizing that the use case for users who simply upgrade dnf without any connection to dnf5 was not included. For these users who haven't installed the latest libdnf5 dependency, it is possible to install/upgrade dnf without dnf.conf being present on the system. This should be fixed now by this PR: https://github.com/rpm-software-management/dnf/pull/1937. Therefore I am switching this to POST.

Comment 9 Jaroslav Mracek 2023-06-05 08:02:27 UTC
Important - the original cause of the bug is not in DNF or in DNF5. The problem is in particular packages that modifies blindly `dnf.conf` by adding come configuration to the end of the file. It is an approach that easily breaks DNF or configuration because dnf.conf may contain more sections then `[main]`. Our solution will again move the cause of the problem to the background.

Comment 10 Jan Pazdziora 2023-06-05 16:47:09 UTC
(In reply to Jaroslav Mracek from comment #9)
> Important - the original cause of the bug is not in DNF or in DNF5. The
> problem is in particular packages that modifies blindly `dnf.conf` by adding
> come configuration to the end of the file. It is an approach that easily
> breaks DNF or configuration because dnf.conf may contain more sections then
> `[main]`.

Except that tsflags=nodocs is not added by any package but by the Fedora base container image definition. Can you please file a bug to track any needed change in the approach for the container images with the right product / component?

> Our solution will again move the cause of the problem to the background.

Could you elaborate what you mean by that?

Comment 11 Fedora Release Engineering 2023-08-16 08:07:45 UTC
This bug appears to have been reported against 'rawhide' during the Fedora Linux 39 development cycle.
Changing version to 39.