From 3e7da14a9a5bf8a6dd739d424b964eb7efe6cabd Mon Sep 17 00:00:00 2001 From: Markus Hilger Date: Mon, 27 Jul 2026 17:02:17 +0200 Subject: [PATCH] Test the import drain loops for an error before a percentage Both loops that read the importer's output test for a percentage first, so an ERROR: line whose text carries a % takes the percentage branch and float() raises instead of the error being reported. The import target name can carry one too, and that one is user supplied. importmedia runs as a bare task, so the exception is swallowed and the client polls a phase that never advances. Test for ERROR: first and treat an unparsable percentage as no percentage. Set percent on the error path of the second loop as well, as the first already does. --- confluent_server/confluent/osimage.py | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/confluent_server/confluent/osimage.py b/confluent_server/confluent/osimage.py index 8f743537..d1f0ae61 100644 --- a/confluent_server/confluent/osimage.py +++ b/confluent_server/confluent/osimage.py @@ -1275,32 +1275,37 @@ class MediaImporter(object): nb = await wkr.stdout.read(128) currline += nb if b'\r' in currline: - if b'%' in currline: - val = currline.split(b'%')[0].strip() - if val: - self.percent = float(val) - elif b'ERROR:' in currline: + if b'ERROR:' in currline: self.error = currline.replace(b'ERROR:', b'') if not isinstance(self.error, str): self.error = self.error.decode('utf8') self.phase = 'error' self.percent = 100.0 return + elif b'%' in currline: + val = currline.split(b'%')[0].strip() + try: + self.percent = float(val) + except ValueError: + pass currline = b'' a = await wkr.stdout.read(1) while a: currline += a if b'\r' in currline: - if b'%' in currline: - val = currline.split(b'%')[0].strip() - if val: - self.percent = float(val) - elif b'ERROR:' in currline: + if b'ERROR:' in currline: self.error = currline.replace(b'ERROR:', b'') if not isinstance(self.error, str): self.error = self.error.decode('utf8') self.phase = 'error' + self.percent = 100.0 return + elif b'%' in currline: + val = currline.split(b'%')[0].strip() + try: + self.percent = float(val) + except ValueError: + pass currline = b'' a = await wkr.stdout.read(1) if self.oscategory: