fix: address review comments

This commit is contained in:
Adam Moussa 2026-08-02 00:57:25 +00:00 • committed by Adam Moussa
parent be0cfce943
commit 308f46eafd
No known key found for this signature in database
2 changed files with 9 additions and 4 deletions

View file

@ -237,6 +237,9 @@ def handle_publish_menu(event):
except json.JSONDecodeError: except json.JSONDecodeError:
return response(400, {"error": "Invalid JSON"}) return response(400, {"error": "Invalid JSON"})
if not isinstance(body, dict):
return response(400, {"error": "Request body must be a JSON object"})
meals = body.get("meals") meals = body.get("meals")
if not isinstance(meals, list) or not meals: if not isinstance(meals, list) or not meals:
return response(400, {"error": "At least one meal is required"}) return response(400, {"error": "At least one meal is required"})

View file

@ -23,6 +23,8 @@ def signed_request(
body: dict | None = None, body: dict | None = None,
region: str = "us-east-1", region: str = "us-east-1",
) -> dict: ) -> dict:
if not api_url.startswith(("http://", "https://")):
raise ValueError(f"api_url must use http(s) scheme: {api_url!r}")
data = json.dumps(body).encode() if body is not None else None data = json.dumps(body).encode() if body is not None else None
headers = {"Content-Type": "application/json"} if data is not None else {} headers = {"Content-Type": "application/json"} if data is not None else {}
request = AWSRequest( request = AWSRequest(