From d21eb38c31f2ad95d5e7a46637df5e5c9b3d0d7e Mon Sep 17 00:00:00 2001 From: Vin Date: Tue, 17 Mar 2026 01:55:50 -0400 Subject: [PATCH] fixed regex for get_trees and timeseries endpoints in FastPheno to accept individual trees via . like 619.03 --- api/resources/fastpheno.py | 4 ++-- tests/resources/test_fastpheno.py | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/api/resources/fastpheno.py b/api/resources/fastpheno.py index 709fe95..bc9fcfa 100644 --- a/api/resources/fastpheno.py +++ b/api/resources/fastpheno.py @@ -83,7 +83,7 @@ def get(self, tree_site_id): tree_site_id = str(escape(tree_site_id)) site = request.args.get("site") - if not re.search(r"^[a-zA-Z0-9]{1,10}$", tree_site_id): + if not re.search(r"^[a-zA-Z0-9.]{1,15}$", tree_site_id): return BARUtils.error_exit("Invalid tree site ID"), 400 if site is not None: @@ -179,7 +179,7 @@ def get(self, tree_site_id, band): band = str(escape(band)) site = request.args.get("site") - if not re.search(r"^[a-zA-Z0-9]{1,10}$", tree_site_id): + if not re.search(r"^[a-zA-Z0-9.]{1,15}$", tree_site_id): return BARUtils.error_exit("Invalid tree site ID"), 400 if not re.search(r"^[a-zA-Z0-9_]{1,20}$", band): diff --git a/tests/resources/test_fastpheno.py b/tests/resources/test_fastpheno.py index bbdba25..302461a 100644 --- a/tests/resources/test_fastpheno.py +++ b/tests/resources/test_fastpheno.py @@ -152,8 +152,8 @@ def test_get_trees(self): expected = {"wasSuccessful": False, "error": "No data found for the given parameters"} self.assertEqual(response.json, expected) - # Invalid tree_site_id (too long) - response = self.app_client.get("/fastpheno/get_trees/TOOLONGID12345") + # Invalid tree_site_id (contains disallowed character) + response = self.app_client.get("/fastpheno/get_trees/619!") expected = {"wasSuccessful": False, "error": "Invalid tree site ID"} self.assertEqual(response.json, expected) @@ -231,8 +231,8 @@ def test_timeseries_genotype_aggregate(self): expected = {"wasSuccessful": False, "error": "No data found for the given parameters"} self.assertEqual(response.json, expected) - # Invalid tree_site_id (too long) - response = self.app_client.get("/fastpheno/timeseries/genotype/TOOLONGID123/398nm/aggregate") + # Invalid tree_site_id (contains disallowed character) + response = self.app_client.get("/fastpheno/timeseries/genotype/619!/398nm/aggregate") expected = {"wasSuccessful": False, "error": "Invalid tree site ID"} self.assertEqual(response.json, expected)