mirror of
https://github.com/stack-auth/stack.git
synced 2026-07-20 21:29:36 +08:00
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.
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user