~sircmpwn/sr.ht#316: 
Prevent duplicate internal oauthtokens from being added to the database

Exception occured on GET https://git.sr.ht/api/repos?start=-1                                                                                                                                             
                                                                                                                                                                                                          
Traceback (most recent call last):                                                                                                                                                                        
  File "/usr/lib/python3.9/site-packages/flask/app.py", line 2073, in wsgi_app                                                                                                                            
    response = self.full_dispatch_request()                                                                                                                                                               
  File "/usr/lib/python3.9/site-packages/flask/app.py", line 1518, in full_dispatch_request                                                                                                               
    rv = self.handle_user_exception(e)                                                                                                                                                                    
  File "/usr/lib/python3.9/site-packages/flask/app.py", line 1516, in full_dispatch_request                                                                                                               
    rv = self.dispatch_request()                                                                                                                                                                          
  File "/usr/lib/python3.9/site-packages/flask/app.py", line 1502, in dispatch_request                                                                                                                    
    return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)                                                                                                                          
  File "/usr/lib/python3.9/site-packages/srht/oauth/decorator.py", line 83, in wrapper                                                                                                                    
    return _internal_auth(f, token[1], *args, **kwargs)                                                                                                                                                   
  File "/usr/lib/python3.9/site-packages/srht/oauth/decorator.py", line 31, in _internal_auth                                                                                                             
    oauth_token = OAuthToken.query.filter(                                                                                                                                                                
  File "/usr/lib/python3.9/site-packages/sqlalchemy/orm/query.py", line 2788, in one_or_none                                                                                                              
    return self._iter().one_or_none()                                                                                                                                                                     
  File "/usr/lib/python3.9/site-packages/sqlalchemy/engine/result.py", line 1373, in one_or_none                                                                                                          
    return self._only_one_row(                                                                                                                                                                            
  File "/usr/lib/python3.9/site-packages/sqlalchemy/engine/result.py", line 613, in _only_one_row                                                                                                         
    raise exc.MultipleResultsFound(                                                                                                                                                                       
sqlalchemy.exc.MultipleResultsFound: Multiple rows were found when one or none was required                                                                                                               

Status
REPORTED
Submitter
~sircmpwn
Assigned to
No-one
Submitted
1 year, 10 months ago
Updated
1 year, 10 months ago
Labels
No labels applied.