← Back to team overview

canonical-ubuntu-qa team mailing list archive

[Merge] ~hyask/autopkgtest-cloud:skia/worker_bad_request into autopkgtest-cloud:master

 

Skia has proposed merging ~hyask/autopkgtest-cloud:skia/worker_bad_request into autopkgtest-cloud:master.

Requested reviews:
  Canonical's Ubuntu QA (canonical-ubuntu-qa)

For more details, see:
https://code.launchpad.net/~hyask/autopkgtest-cloud/+git/autopkgtest-cloud/+merge/463341

This is in reaction to some 'invalid request' errors we've been seeing recently.
-- 
Your team Canonical's Ubuntu QA is requested to review the proposed merge of ~hyask/autopkgtest-cloud:skia/worker_bad_request into autopkgtest-cloud:master.
diff --git a/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/worker/worker b/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/worker/worker
index 680b28e..706222b 100755
--- a/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/worker/worker
+++ b/charms/focal/autopkgtest-cloud-worker/autopkgtest-cloud/worker/worker
@@ -649,14 +649,16 @@ def request(msg):
 
     # request is either a single string pkgname or "pkg_name json_params"
     try:
-        req = body.split(None, 1)
+        req = body.split("\n", 1)
         pkgname = req[0]
         if len(req) > 1:
             params = json.loads(req[1])
         else:
             params = {}
-    except (ValueError, IndexError):
-        logging.error('Received invalid request format "%s"', body)
+    except (ValueError, IndexError) as e:
+        logging.error(
+            'Received invalid request format "%s" (%s)', body, repr(e)
+        )
         return
     test_uuid = params.get("uuid", str(uuid.uuid4()))
     if not re.match("[a-zA-Z0-9.+-]+$", pkgname):