Skip to content

Commit 464136c

Browse files
authored
Require / prefix on URL paths in Python (#1457)
1 parent 850122a commit 464136c

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

python/ccf/clients.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ def call(
533533
"""
534534
Issues one request, synchronously, and returns the response.
535535
536-
:param str path: URI of the targeted resource.
536+
:param str path: URI of the targeted resource. Must begin with '/'
537537
:param dict body: Request body (optional).
538538
:param str http_verb: HTTP verb (e.g. "POST" or "GET").
539539
:param dict headers: HTTP request headers (optional).
@@ -542,6 +542,9 @@ def call(
542542
543543
:return: :py:class:`ccf.clients.Response`
544544
"""
545+
if not path.startswith("/"):
546+
raise ValueError(f"URL path '{path}' is invalid, must start with /")
547+
545548
if self.is_connected:
546549
return self._direct_call(path, body, http_verb, headers, signed, timeout)
547550

tests/suite/test_requirements.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def check(network, args, *nargs, **kwargs):
9292
primary, _ = network.find_primary()
9393
with primary.client("member0") as c:
9494
r = c.post(
95-
"gov/query",
95+
"/gov/query",
9696
{
9797
"text": """tables = ...
9898
trusted_nodes_count = 0

0 commit comments

Comments
 (0)