From 011b658805ba67ed41eb55768c4591ca8f86eae1 Mon Sep 17 00:00:00 2001 From: Enrico204 Date: Mon, 6 Feb 2023 13:52:07 +0100 Subject: [PATCH] Use empty username when username is not present in snapshot. This commit is fixing a crash when the snapshot has no username field in JSON. The missing username is replaced with a space. --- restic-exporter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/restic-exporter.py b/restic-exporter.py index 08799e5..3ee9f02 100644 --- a/restic-exporter.py +++ b/restic-exporter.py @@ -117,7 +117,7 @@ class ResticCollector(object): clients.append({ 'snapshot_hash': snap['hash'], 'hostname': snap['hostname'], - 'username': snap['username'], + 'username': snap['username'] if 'username' in snap else '', 'timestamp': timestamp, 'size_total': stats['total_size'], 'files_total': stats['total_file_count'],