1818 - default common http headers (CORS and Cache Control)
1919
2020"""
21-
2221import logging
2322
2423import 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