Bug 2007166

Summary: Module yaml error: Unexpected key in data
Product: Red Hat Enterprise Linux 9 Reporter: Petr Pisar <ppisar>
Component: libdnfAssignee: amatej
Status: CLOSED ERRATA QA Contact: Eva Mrakova <emrakova>
Severity: high Docs Contact:
Priority: urgent    
Version: 9.0CC: amatej, jmracek, jrohel, mblaha, mhatina, nphilipp, packaging-team-maint, pkratoch, ppisar, tbajer, user-cont-team+packit-fas, vmukhame
Target Milestone: rcKeywords: Triaged
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libdnf-0.65.0-1.el9 Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of: 2004853
: 2007167 (view as bug list) Environment:
Last Closed: 2022-05-17 15:55:20 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:
Bug Depends On: 2006669    
Bug Blocks:    

Description Petr Pisar 2021-09-23 09:44:28 UTC
+++ This bug was initially created as a clone of Bug #2004853 +++

Since today (2021-09-16) I am not able to install some packages on a clean install of https://archives.fedoraproject.org/pub/fedora/linux/releases/33/Cloud/x86_64/images/Fedora-Cloud-Base-33-1.2.x86_64.qcow2. It's "clean" in the sense that it's fetched and passed directly to a packer instance which then provisions the entire VM so there's no work done inside the image prior that process. Example:

[root@fedora33-cloud-31864 spdk]# dnf install -y autoconf
[...]
Module yaml error: Unexpected key in data: static_context [line 9 col 3]
Module yaml error: Unexpected key in data: static_context [line 9 col 3]
Module yaml error: Unexpected key in data: static_context [line 9 col 3]
Module yaml error: Unexpected key in data: static_context [line 9 col 3]
Dependencies resolved.
[...]
Running transaction check
No available modular metadata for modular package 'perl-AutoLoader-5.74-471.module_f33+12592+71aff0e2.noarch', it cannot be installed on the system
No available modular metadata for modular package 'perl-B-1.80-471.module_f33+12592+71aff0e2.x86_64', it cannot be installed on the system
[...]
Error: No available modular metadata for modular package
[...]

--- Additional comment from Petr Pisar on 2021-09-21 08:28:13 GMT ---

This is caused by DNF which explicitly strictly validates modulemd-v2 documents before using them. 
Since the old libmodulemd 2.9.4 does not recognize static_context field, it reports that the document is not strictly valid and DNF will discard it.
Because DNF discards all documents in a modular repository, it errors with "No available modular metadata for modular package".

DNF needs stop strictly validating the documents. Without strict validation, old libmodulemd will ignore unknown fields and DNF will happily consume them.

You can work around the DNF issues by upgrading libmodulemd first. Then subsequent invocations of DNF will recognize the same documents as valid. Because you use DNF for updating libmodulemd (and dnf, once fixed), you need temporarily disable modular repositories "dnf --disable-repo 'fedora-modular*' upgrade libmodulemd".

[...]

--- Additional comment from  on 2021-09-22 10:41:40 GMT ---

I made a PR that switches off the strict validation for dnf (it is done through libdnf) https://github.com/rpm-software-management/libdnf/pull/1346.

-----

RHEL-9 is affected (libdnf-0.63.0-4.el9).

We need to apply this fix to enable future enhancements of the modulemd-v2 format. Without the fix DNF would leak packages of the new modules into non-modular package set.

Comment 7 errata-xmlrpc 2022-05-17 15:55:20 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 (new packages: libdnf), 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-2022:3959