-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Increase attachment upload verbosity #17
Comments
I think that's a general issue we have in sw360python. I can't exactly recall details, but I've already seen cases where other non-critical issues are also silently ignored. From the concept of the SW360 moderation requests, I would argue that the attachment has been properly transferred if you get 202 (which is also in the 2xx success range). As it might take an unpredictable time in practice until the moderation request is acted upon and the user uploading things is confused not to see the attachments, I however agree we should somehow inform the user. But not via an exception as this might abort surrounding code while the operation succeeded in some way. I think the proper answer here would be to add logging means to our library. Do you have recommendations for this, @deveaud-m? |
The other option would be to make details on the actual request available to the caller - something which I also missed already in some cases (e.g. to get the body with the error message in case an error occured). But this would probably break our complete API which is probably not what we want to do. Any ideas? |
I would use We can start with the I can start with #18 if that makes sense and log a |
202 indicates success (accepted), so I would not expect an expection. Regarding logging: yes, this might be a solution, but if we use normal logging and debug messages, then we get a lot of messages from the request library... Getting the body of an error message IS possible ...but not straight forward. |
Logging messages from the request library can be filtered-out: import logging
# Only show warnings
logging.getLogger("urllib3").setLevel(logging.WARNING)
# Disable all child loggers of urllib3, e.g. urllib3.connectionpool
logging.getLogger("urllib3").propagate = False Would this be the preferred way to propagate information from this SW360 library to the clients? |
As So my answer would be yes. 😸 @tngraf, what do you think? |
Only two scenarios are covered by the API function
upload_resource_attachment()
:response.ok
does not raiseresponse.ok
raisesSW360Error
If the HTTP response received for this call is
202
, the function call simply returns however the attachment has not been uploaded to the e.g. component but a moderation request has been created. Example of the received response:In that case the client should be informed about the result of the call instead of expecting that the attachment has properly been transferred.
/cc @t-graf @gernot-h
The text was updated successfully, but these errors were encountered: