From b44fabc6233f16513039900f9fa0e58ca13cb82e Mon Sep 17 00:00:00 2001 From: Ejiro Asiuwhu Date: Thu, 26 Mar 2026 10:36:55 +0100 Subject: [PATCH] fix: validate mutually exclusive product_id/product in grant_product The spec requires exactly one of product_id or product (inline definition). Added validation to both sync and async grant_product methods to raise ValueError if both or neither are provided, matching the existing _resolve_customer_path pattern for customer identifiers. --- sdks/implementations/python/src/stack_auth/_app.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sdks/implementations/python/src/stack_auth/_app.py b/sdks/implementations/python/src/stack_auth/_app.py index 923fa39b7..e07188861 100644 --- a/sdks/implementations/python/src/stack_auth/_app.py +++ b/sdks/implementations/python/src/stack_auth/_app.py @@ -1299,8 +1299,11 @@ class StackServerApp: None. Raises: - ValueError: If not exactly one customer identifier is provided. + ValueError: If not exactly one customer identifier is provided, + or if both/neither of product_id and product are given. """ + if (product_id is None) == (product is None): + raise ValueError("Provide exactly one of product_id or product, not both or neither") ctype, cid, _ = _resolve_customer_path(user_id, team_id, custom_customer_id) body = _build_params( product_id=product_id, @@ -2650,8 +2653,11 @@ class AsyncStackServerApp: None. Raises: - ValueError: If not exactly one customer identifier is provided. + ValueError: If not exactly one customer identifier is provided, + or if both/neither of product_id and product are given. """ + if (product_id is None) == (product is None): + raise ValueError("Provide exactly one of product_id or product, not both or neither") ctype, cid, _ = _resolve_customer_path(user_id, team_id, custom_customer_id) body = _build_params( product_id=product_id,