From 0a0f0d99bd16e4f46da64c19238dbabf72534d93 Mon Sep 17 00:00:00 2001 From: Jeffrey Wong Date: Sun, 15 Nov 2026 16:51:17 -0600 Subject: [PATCH] athena: upload requests without headers are accepted again --- openpilot/system/athena/athenad.py | 4 +-- openpilot/system/athena/tests/test_athenad.py | 31 +++++++++++++++++++ prebuilt.json | 2 +- 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/openpilot/system/athena/athenad.py b/openpilot/system/athena/athenad.py index fd26a8105e..f552de7078 100755 --- a/openpilot/system/athena/athenad.py +++ b/openpilot/system/athena/athenad.py @@ -92,8 +92,8 @@ UPLOAD_URL = regex(r'https?://[\x21-\x7e]+') UPLOAD_HEADERS = dict_of(regex(r'[\w\-]+'), regex(r'[\x20-\x7e]*')) UPLOAD_ID = regex(r'[0-9a-f]{40}') CLIP_FILENAME = regex(r'[\w\-][\w\-.]*') -UPLOAD_FILE = struct({"fn": regex(DATA_PATH), "url": UPLOAD_URL, "headers": UPLOAD_HEADERS}, - {"allow_cellular": boolean, "priority": integer(0, DEFAULT_UPLOAD_PRIORITY)}) +UPLOAD_FILE = struct({"fn": regex(DATA_PATH), "url": UPLOAD_URL}, + {"headers": UPLOAD_HEADERS, "allow_cellular": boolean, "priority": integer(0, DEFAULT_UPLOAD_PRIORITY)}) class UploadTOSAdapter(HTTPAdapter): diff --git a/openpilot/system/athena/tests/test_athenad.py b/openpilot/system/athena/tests/test_athenad.py index c02bc4a7cd..7ada9ccfca 100644 --- a/openpilot/system/athena/tests/test_athenad.py +++ b/openpilot/system/athena/tests/test_athenad.py @@ -278,6 +278,37 @@ class TestAthenadMethods(OpenpilotTestCase): assert resp['items'][0].get('id') is not None assert athenad.upload_queue.qsize() == 1 + @parameterized.expand([None, {}, {"Content-Type": "application/octet-stream"}], names=("headers",)) + def test_upload_files_optional_headers(self, headers): + files = [] + for name in ("rlog.zst", "fcamera.hevc"): + self._create_file(name) + item = {"fn": f"2026-10-04--00-00-00--0/{name}", "url": f"https://upload.example/{name}?signature=signed"} + if headers is not None: + item["headers"] = headers + files.append(item) + response = dispatcher["uploadFilesToUrls"](files) + assert response["enqueued"] == 2 and "failed" not in response + assert athenad.upload_queue.qsize() == 2 + for requested, queued in zip(files, response["items"], strict=True): + assert queued["url"] == requested["url"] + assert queued["headers"] == (headers if headers is not None else {}) + assert queued["allow_cellular"] is False + assert queued["priority"] == athenad.DEFAULT_UPLOAD_PRIORITY + + @parameterized.expand([ + {"headers": None}, {"headers": []}, {"headers": {"bad header": "value"}}, + {"headers": {"X-Test": "value\r\nInjected: bad"}}, {"headers": {"X-Test": 1}}, + {"fn": "../rlog.zst"}, {"fn": "/rlog.zst"}, {"url": "file:///tmp/rlog.zst"}, + {"allow_cellular": 1}, {"priority": -1}, {"priority": True}, {"extra": True}, + ], names=("invalid",)) + def test_upload_files_invalid_batch_is_not_partially_queued(self, invalid): + self._create_file("rlog.zst") + valid = {"fn": "2026-10-04--00-00-00--0/rlog.zst", "url": "https://upload.example/rlog.zst?signature=signed"} + with self.assertRaisesRegex(TypeError, "invalid param: files_data"): + dispatcher["uploadFilesToUrls"]([valid, valid | invalid]) + assert athenad.upload_queue.empty() + def test_upload_file_to_url_duplicate(self, host): self._create_file('qlog.zst') diff --git a/prebuilt.json b/prebuilt.json index 7760e1710b..54ecba8a02 100644 --- a/prebuilt.json +++ b/prebuilt.json @@ -1 +1 @@ -{"protected_inventory_sha256": "7ebc31245425508c47258b7573c8fc12c41404d6cea61e9dde5d9c88dece11bb", "schema_version": 1} +{"protected_inventory_sha256": "babded498136ff08ce705f8ec7ac8946b1e86eb1cd4e32a777b32b5ac0643fe5", "schema_version": 1}