summary refs log tree commit diff
path: root/synapse/rest/client
diff options
context:
space:
mode:
authorDenis Kasak <dkasak@termina.org.uk>2024-06-24 15:12:14 +0200
committerGitHub <noreply@github.com>2024-06-24 15:12:14 +0200
commit700d2cc4a0d457642edb43bc3714d212f15d797f (patch)
treefc338a7d0cd2649b3dba0992e9e8c59e2ac1c349 /synapse/rest/client
parentBump lazy_static from 1.4.0 to 1.5.0 (#17355) (diff)
downloadsynapse-700d2cc4a0d457642edb43bc3714d212f15d797f.tar.xz
Tidy up integer parsing (#17339)
The parse_integer function was previously made to reject negative values by
default in https://github.com/element-hq/synapse/pull/16920, but the
documentation stated otherwise. This fixes the documentation and also:

- Removes explicit negative=False parameters from call sites.
- Brings the negative default of parse_integer_from_args in alignment with
  parse_integer.
Diffstat (limited to 'synapse/rest/client')
-rw-r--r--synapse/rest/client/room.py11
1 files changed, 1 insertions, 10 deletions
diff --git a/synapse/rest/client/room.py b/synapse/rest/client/room.py
index c98241f6ce..bd65cf4b83 100644
--- a/synapse/rest/client/room.py
+++ b/synapse/rest/client/room.py
@@ -510,7 +510,7 @@ class PublicRoomListRestServlet(RestServlet):
             if server:
                 raise e
 
-        limit: Optional[int] = parse_integer(request, "limit", 0, negative=False)
+        limit: Optional[int] = parse_integer(request, "limit", 0)
         since_token = parse_string(request, "since")
 
         if limit == 0:
@@ -1430,16 +1430,7 @@ class RoomHierarchyRestServlet(RestServlet):
         requester = await self._auth.get_user_by_req(request, allow_guest=True)
 
         max_depth = parse_integer(request, "max_depth")
-        if max_depth is not None and max_depth < 0:
-            raise SynapseError(
-                400, "'max_depth' must be a non-negative integer", Codes.BAD_JSON
-            )
-
         limit = parse_integer(request, "limit")
-        if limit is not None and limit <= 0:
-            raise SynapseError(
-                400, "'limit' must be a positive integer", Codes.BAD_JSON
-            )
 
         return 200, await self._room_summary_handler.get_room_hierarchy(
             requester,