dnf Module yaml error: Unexpected key in data

While applying recent updates to a server running Rocky Linux 8, an error presented itself.

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]

The solution turned out to be a simple one. Update the libmodulemd first to correct the problem then perform the dnf updates as usual.

dnf update libmodulemd

For a detailed explanation as to the cause of this problem.

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".


  • https://bugzilla.redhat.com/show_bug.cgi?id=2007166