Skip to content

Commit f297a18

Browse files
Merge branch '1.0.x'
2 parents 07a5d42 + f0cd4a0 commit f297a18

File tree

3 files changed

+32
-3
lines changed

3 files changed

+32
-3
lines changed

CHANGES.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
v1.0.1 (2025/08/21)
2+
Bugfixes:
3+
- Fixed parameter validation conflict by requiring handler classes with `kwargs` to define a unique `name` attribute. ([#412](https://github.com/biothings/biothings.api/pull/412))
4+
- Fix missing dependencies for building sphinx docs
15
v1.0.0 (2025/07/29)
26
Highlights:
37
- Support sqlite3 for the MergerStorage backend, e.g. used in CLI ([#348](https://github.com/biothings/biothings.api/pull/348))

biothings/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class _version_info(NamedTuple):
88
micro: int
99

1010

11-
version_info = _version_info(1, 0, 0)
11+
version_info = _version_info(1, 0, 1)
1212
__version__ = ".".join(map(str, version_info))
1313

1414

biothings/web/handlers/base.py

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
- default common http headers (CORS and Cache Control)
1919
2020
"""
21-
2221
import logging
2322

2423
import orjson
@@ -94,7 +93,13 @@ def prepare(self):
9493
)
9594
# standardized request arguments
9695
self.args = self._parse_args(reqargs)
97-
self.format = self.args.format
96+
97+
# Handle cases where args is a plain dict (e.g., when name is missing or None)
98+
if hasattr(self.args, 'format'):
99+
self.format = self.args.format
100+
else:
101+
# Use the default format when args doesn't have format attribute
102+
self.format = "json"
98103

99104
def _parse_json(self):
100105
if not self.request.body:
@@ -114,6 +119,26 @@ def _parse_args(self, reqargs):
114119
if not self.name: # feature disabled
115120
return {} # default value
116121

122+
# Check if handler defines kwargs but not a unique name - this is an error
123+
if self.name == "__base__" and self.__class__ != BaseAPIHandler:
124+
# Check if this handler defines its own kwargs (not inherited from BaseAPIHandler)
125+
handler_has_kwargs = (
126+
hasattr(self.__class__, 'kwargs') and
127+
self.__class__.kwargs is not BaseAPIHandler.kwargs
128+
)
129+
130+
if handler_has_kwargs:
131+
# Handler defines kwargs but uses default name - this will cause conflicts
132+
raise ValueError(
133+
f"Handler {self.__class__.__name__} defines 'kwargs' but doesn't define "
134+
f"a unique 'name' attribute. This causes parameter validation conflicts. "
135+
f"Please add: name = 'your_handler_name' to the class definition."
136+
)
137+
else:
138+
# Handler doesn't define kwargs and doesn't define name - this is ok
139+
# Return empty args to disable parameter validation
140+
return {}
141+
117142
optionsets = self.biothings.optionsets
118143
optionset = optionsets.get(self.name)
119144

0 commit comments

Comments
 (0)