Comments (3)
@gcoxmoz Thanks for your thoughts on this. We use this library internally at Duo, so I'll run your ideas past some of our internal folks and see what they think.
from duo_client_python.
@gcoxmoz Thanks for bringing this up. Overall, I would say the lack of try blocks is our intended design, since as a pure client, there's nothing particularly useful we can do when a request goes wrong. Is there something you have in mind that you'd like to see us do with this type of error?
from duo_client_python.
https://duo.com/docs/authapi#/check basically says an API should expect 200 or 401 on a check
call. Since you didn't get that, the exception bubbled all the way through your code, to my code, as a confusing "BadStatusLine".
My thought here is that, since I'm not writing http-level code / you're providing the python API and you might change your http library underpinnings, it's very difficult for me to do something better in my own scripting than 'catch all exceptions', without doing a vast amount of study and following your library down through the next layer, now and in the future. That is, it feels like it's weird for you to ever raise 'BadStatusLine' (ok, technically "allow to raise through you"), and I don't know what else you might raise from that library (or others), and if it'll ever change.
Ultimately the question, I think, is "should duo_client_python encapsulate its own sublibraries?" Both from laziness and neatness, I think so. The API docs are super short and only show cases of 201/400, and obviously the web can fail you on occasion, which means the libraries can fail us. But I'm two levels removed from httplib here.
I think the elegant approach here would be to catch 'BadStatusLine' in _attempt_single_request
(and other errors you might get in testing/bug reports over time) and re-wrap / re-raise them as a duo_client_python defined Exception, so that I have a known Exception to catch. Basically an exception that says "the duo_client API failed to get a valid response from the REST API, you need to handle it." That way I know what exception type to capture (because it's defined by you), and you aren't leaking someone else's exceptions.
from duo_client_python.
Related Issues (20)
- Add Support Create Integration for SSO type HOT 5
- Update Admin cannot update the status HOT 1
- Deprecated SSL protocol in CertValidatingHTTPSConnection HOT 4
- Interators not working due to not having metadata populated HOT 5
- 403 Forbidden Access on all methods of Admin API HOT 6
- Duo: no library to generate passcodes HOT 4
- get_authentication_log - api:v2 param filter failing HOT 4
- metadata parse error in add_user_phone HOT 4
- Automatic proxy configuration HOT 2
- get_authentication_log clearing out Params HOT 3
- Add Get User by Email HOT 1
- 400 Bad Request response when trying to add a token for a yubikey HOT 1
- Duo client installed via pip is missing the get_users_by_names func HOT 3
- Getting "Received 429 Too Many Requests" for auth logs even if hitting the API in 6-7 minute intervals
- Getting 40103 on making GET REST API calls HOT 5
- Tests are failing because actual requests are being made HOT 1
- How to use duo_client_python to access an integrations secret key? HOT 2
- next_offset pagination in auth logs HOT 12
- add get auth summary endpoint to the admin object
- bad link in READ.me
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from duo_client_python.