From 0961711b61d8f7ccd9384ce7e4eeb6b4a7c68b5b Mon Sep 17 00:00:00 2001 From: chronolaw Date: Mon, 13 May 2024 16:30:08 +0800 Subject: [PATCH] fix(db/schema): do not allow setting priority with traditional route fields in mixed mode --- kong/db/schema/entities/routes.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/kong/db/schema/entities/routes.lua b/kong/db/schema/entities/routes.lua index 0d3558557d4f..8053823b4f90 100644 --- a/kong/db/schema/entities/routes.lua +++ b/kong/db/schema/entities/routes.lua @@ -84,6 +84,19 @@ if kong_router_flavor == "traditional_compatible" or kong_router_flavor == "expr "simultaneously" end + if not is_expression_empty and not is_null(entity.regex_priority) then + return nil, "Router Expression failed validation: " .. + "cannot set 'regex_priority' with 'expression' " .. + "simultaneously" + end + + if not is_others_empty and not is_null(entity.priority) then + return nil, "Router Expression failed validation: " .. + "cannot set 'priority' with " .. + "'methods', 'hosts', 'paths', 'headers', 'snis', 'sources' or 'destinations' " .. + "simultaneously" + end + local schema = get_schema(entity.protocols) local exp = get_expression(entity)