From 884ddb417ed88712d708835d34064b182b2a8fb1 Mon Sep 17 00:00:00 2001 From: dirkhub <71777632+dirkhub@users.noreply.github.com> Date: Thu, 8 Oct 2026 14:22:01 +0200 Subject: [PATCH] tolerate unknonwn filetypes in tarinfo Tolerate unknown filetypes for omd backup. Simply ignore them, rather than aborting the whole backup with an exception. --- omd/packages/omd/omdlib/backup.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/omd/packages/omd/omdlib/backup.py b/omd/packages/omd/omdlib/backup.py index 56deb91bbfc..b7af63d274d 100644 --- a/omd/packages/omd/omdlib/backup.py +++ b/omd/packages/omd/omdlib/backup.py @@ -3,6 +3,9 @@ # This file is part of Checkmk (https://checkmk.com). It is subject to the terms and # conditions defined in the file COPYING, which is part of this source code package. +# mypy: disable-error-code="comparison-overlap" +# mypy: disable-error-code="redundant-expr" + """Cares about backing up the files of a site""" import contextlib @@ -384,7 +387,7 @@ def _tar_add( # Create a TarInfo object from the file. tarinfo = _get_tar_info_or_raise(tar, name, arcname) # Exclude files. - if not predicate(tarinfo): + if tarinfo is None or not predicate(tarinfo): return # Create a backup of history file and add it to the archive as history.sqlite. @@ -469,5 +472,6 @@ def _get_tar_info_or_raise( """ tarinfo: tarfile.TarInfo | None = tar.gettarinfo(name, arcname=arcname) if tarinfo is None: - raise tarfile.TarError(f"Failed to get tarinfo for file {name!r}") + # raise tarfile.TarError(f"Failed to get tarinfo for file {name!r}") + return None # tolerate unkown file types and simply ignore them for the backup return tarinfo