From dadbd58af59f7d0c8f421de3c8a6d975d619c6a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Hozza?= Date: Thu, 11 Jan 2024 15:49:31 +0100 Subject: [PATCH] LoadAllRepositories: don't fail on filenames which can't be parsed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, the `LoadAllRepositories()` function used repo file filename as the distro name, without inspecting it. Now that we parse it, the failure to parse the filename as the distro ID string was considered an error. This may cause osbuild-composer fail to start due to failure while loading repositories. Let's use the repo file filename as is as the distro name, if parsing it fails. Signed-off-by: Tomáš Hozza --- pkg/reporegistry/repository.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/reporegistry/repository.go b/pkg/reporegistry/repository.go index c7d3dbb858..a65e194681 100644 --- a/pkg/reporegistry/repository.go +++ b/pkg/reporegistry/repository.go @@ -40,7 +40,11 @@ func LoadAllRepositories(confPaths []string) (rpmmd.DistrosRepoConfigs, error) { // without a dot to separate major and minor release versions distro, err := distroidparser.DefaultParser.Standardize(distroIDStr) if err != nil { - return nil, fmt.Errorf("failed to parse distro ID string: %v", err) + log.Printf("failed to parse distro ID string, using it as is: %v", err) + // NB: Before the introduction of distro ID standardization, the filename + // was used as the distro ID. This is kept for backward compatibility + // if the filename can't be parsed. + distro = distroIDStr } // skip the distro repos definition, if it has been already read