fix: pre-car-test bug fixes from full code audit

- app_alerts.py: null guard on list_local_videos() result (.get('files', []))
- app_cellular.py: remove erroneous .encode(errors='replace') on str response body
- app_settings.py: initialize apn='' when isinstance check fails (NameError guard)
- app_upload.py: move json import to top of file instead of inside except handler
- server/app.py: wrap int(request.args.get('limit')) in try/except ValueError
- server/app.py: wrap os.path.commonpath() in try/except ValueError (cross-root paths)
- tests/test_app_settings.py: add missing trips_upload_enabled/video_convert_enabled
  to valid_payload() (fields added in Phase 23.5 but test not updated)

All 63 tests pass.

Co-authored-by: Copilot <[email protected]>
This commit is contained in:
Mathieu Moran
2026-08-10 05:15:27 -04:00
co-authored by Copilot
parent f30143c7b7
commit 1b39ac0cc8
6 changed files with 20 additions and 8 deletions
+1
View File
@@ -121,6 +121,7 @@ def update_settings(body):
apn = body.get("cellular_apn")
if not isinstance(apn, str):
errors["cellular_apn"] = "Must be text."
apn = ""
else:
apn = apn.strip()
if len(apn) > 100 or not _APN_PATTERN.fullmatch(apn):