Skip to content

Commit

Permalink
Merge pull request #1775 from PolicyEngine/fix/419-check-for-malforme…
Browse files Browse the repository at this point in the history
…d-country_id-in-get_analysis

Check for invalid/malformed country ID in get_analysis endpoint
  • Loading branch information
anth-volk authored Sep 20, 2024
2 parents 1476132 + c0e2118 commit 62b9c9f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions changelog_entry.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- bump: minor
changes:
added:
- Added check for invalid country in get_analysis endpoint
4 changes: 4 additions & 0 deletions policyengine_api/endpoints/analysis.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
from policyengine_api.country import validate_country
from policyengine_api.data import local_database
from policyengine_api.utils import hash_object
import time
Expand Down Expand Up @@ -79,6 +80,9 @@ def trigger_policy_analysis(prompt: str, prompt_id: int):


def get_analysis(country_id: str, prompt_id=None):
invalid_country = validate_country(country_id)
if invalid_country:
return invalid_country
try:
prompt = flask.request.json.get("prompt")
except:
Expand Down

0 comments on commit 62b9c9f

Please sign in to comment.