|
60 | 60 | # 16-Feb-2024 rbd 0.6 For Platform 7, common DeviceState property. |
61 | 61 | # New StateValue object, and enhance PropertyResponse to |
62 | 62 | # serialize objects into JSON (the StateValue objects). |
| 63 | +# 16-Feb-2025 rbd 1.0.2 Issue #17 Correct handling of ClientID and |
| 64 | +# ClientTransactionID. Add missing keywords to some Falcon |
| 65 | +# HTTPBadRequest exceptions to prevent deprecation warnings. |
63 | 66 |
|
64 | 67 | from threading import Lock |
65 | 68 | from exceptions import Success |
@@ -187,21 +190,21 @@ def _check_request(self, req: Request, devnum: int): # Raise on failure |
187 | 190 | if devnum > self.maxdev: |
188 | 191 | msg = f'Device number {str(devnum)} does not exist. Maximum device number is {self.maxdev}.' |
189 | 192 | logger.error(msg) |
190 | | - raise HTTPBadRequest(_bad_title, msg) |
191 | | - test: str = get_request_field('ClientID', req, True) # Caseless |
192 | | - if test is None: |
193 | | - msg = 'Request has missing Alpaca ClientID value' |
194 | | - logger.error(msg) |
195 | | - raise HTTPBadRequest(_bad_title, msg) |
| 193 | + raise HTTPBadRequest(title=_bad_title, description=msg) |
| 194 | + test: str = get_request_field('ClientID', req, True, '0') # Caseless, default = 0 if missing |
196 | 195 | if not self._pos_or_zero(test): |
197 | 196 | msg = f'Request has bad Alpaca ClientID value {test}' |
198 | 197 | logger.error(msg) |
199 | | - raise HTTPBadRequest(_bad_title, msg) |
200 | | - test: str = get_request_field('ClientTransactionID', req, True) |
| 198 | + raise HTTPBadRequest(title=_bad_title, description=msg) |
| 199 | + if test == '0': |
| 200 | + req.params['ClientID'] = '0' # In case it's missing |
| 201 | + test: str = get_request_field('ClientTransactionID', req, True, '0') # Caseless, default = 0 if missing |
201 | 202 | if not self._pos_or_zero(test): |
202 | 203 | msg = f'Request has bad Alpaca ClientTransactionID value {test}' |
203 | 204 | logger.error(msg) |
204 | | - raise HTTPBadRequest(_bad_title, msg) |
| 205 | + raise HTTPBadRequest(title=_bad_title, description=msg) |
| 206 | + if test == '0': |
| 207 | + req.params['ClientTransactionID'] = '0' # In case it's missing |
205 | 208 |
|
206 | 209 | # |
207 | 210 | # params contains {'devnum': n } from the URI template matcher |
|
0 commit comments