fedora-modularity / libmodulemd

C Library for manipulating module metadata files
MIT License
31 stars 52 forks source link

modulemd-packager-v3: Reject duplicate context #576

Closed ppisar closed 3 years ago

ppisar commented 3 years ago

A specification requires modulemd-packager-v3 documents to have context values unique among all configurations:

document: modulemd-packager version: 3 data: name: foo stream: bar license: [MIT] configurations:

That was not enforced and previous configurations were swallowed by the last one.

This patch fixes it.

I was tempting to augment modulemd_packager_v3_add_build_config(), but that cannot change a prototype because it's passed to COPY_HASHTABLE_BY_VALUE_ADDER(). A wrapper for an error-returning variant would be too cluttery and glib < 2.40 does not report a replacement. Next, augmenting modulemd_build_config_parse_yaml() would bring the benefit of reporting a line number, but feeding a packager object down to the YAML parser would be against separating a data flow. Thus I simply added a condition just before calling modulemd_packager_v3_add_build_config().