From 8b24c44fb9fcad2d120e5b5b65a27c5bb8b206cc Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Mon, 6 Nov 2023 14:44:00 +0000 Subject: [PATCH 1/4] fix: proxy create rule 500 --- app/controllers/api/proxy.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/controllers/api/proxy.php b/app/controllers/api/proxy.php index f9621fb05a..0d1428cf23 100644 --- a/app/controllers/api/proxy.php +++ b/app/controllers/api/proxy.php @@ -87,8 +87,12 @@ App::post('/v1/proxy/rules') $resourceInternalId = $function->getInternalId(); } - $domain = new Domain($domain); - + try { + $domain = new Domain($domain); + } catch (Exception) { + throw new Exception(Exception::GENERAL_ARGUMENT_INVALID, 'Invalid domain. Domain may not start with http:// or https://.'); + } + $ruleId = ID::unique(); $rule = new Document([ '$id' => $ruleId, From 61c5f371b754146383e7b65126611b18917b856b Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Mon, 6 Nov 2023 14:45:56 +0000 Subject: [PATCH 2/4] chore: use base Exception --- app/controllers/api/proxy.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/api/proxy.php b/app/controllers/api/proxy.php index 0d1428cf23..9bfb546b95 100644 --- a/app/controllers/api/proxy.php +++ b/app/controllers/api/proxy.php @@ -89,7 +89,7 @@ App::post('/v1/proxy/rules') try { $domain = new Domain($domain); - } catch (Exception) { + } catch (\Exception) { throw new Exception(Exception::GENERAL_ARGUMENT_INVALID, 'Invalid domain. Domain may not start with http:// or https://.'); } From 4440859c0565b35a2da8778330f65793ae2d3be8 Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Mon, 6 Nov 2023 14:48:54 +0000 Subject: [PATCH 3/4] chore: fmt --- app/controllers/api/proxy.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/api/proxy.php b/app/controllers/api/proxy.php index 9bfb546b95..6b93912a2a 100644 --- a/app/controllers/api/proxy.php +++ b/app/controllers/api/proxy.php @@ -92,7 +92,7 @@ App::post('/v1/proxy/rules') } catch (\Exception) { throw new Exception(Exception::GENERAL_ARGUMENT_INVALID, 'Invalid domain. Domain may not start with http:// or https://.'); } - + $ruleId = ID::unique(); $rule = new Document([ '$id' => $ruleId, From 75669b9b2ea59815e7ecabd87aba25ccb32fd18f Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Mon, 6 Nov 2023 14:49:33 +0000 Subject: [PATCH 4/4] chore: better error msg --- app/controllers/api/proxy.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/api/proxy.php b/app/controllers/api/proxy.php index 6b93912a2a..23916a114c 100644 --- a/app/controllers/api/proxy.php +++ b/app/controllers/api/proxy.php @@ -90,7 +90,7 @@ App::post('/v1/proxy/rules') try { $domain = new Domain($domain); } catch (\Exception) { - throw new Exception(Exception::GENERAL_ARGUMENT_INVALID, 'Invalid domain. Domain may not start with http:// or https://.'); + throw new Exception(Exception::GENERAL_ARGUMENT_INVALID, 'Domain may not start with http:// or https://.'); } $ruleId = ID::unique();