-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
fix: LEAP-1805: revisit S3 exceptions behavior #7015
base: develop
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for label-studio-docs-new-theme canceled.
|
✅ Deploy Preview for heartex-docs canceled.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add a simple test there?
import pytest
from unittest.mock import patch, MagicMock
from your_module import catch_and_reraise_from_none, S3StorageError
def test_catch_and_reraise_from_none_with_untrusted_domain():
class TestClass:
s3_endpoint = 'http://untrusted-domain.com'
instance = TestClass()
@catch_and_reraise_from_none
def function_to_test(self):
raise Exception("Original Exception")
with patch('your_module.extractor.extract_urllib') as mock_extract:
mock_extract.return_value.registered_domain = 'untrusted-domain.com'
with patch('your_module.settings.S3_TRUSTED_STORAGE_DOMAINS', ['trusted-domain.com']):
with pytest.raises(S3StorageError) as excinfo:
function_to_test(instance)
assert "Debugging info is not available for s3 endpoints on domain: untrusted-domain.com" in str(excinfo.value)
def test_catch_and_reraise_from_none_with_trusted_domain():
class TestClass:
s3_endpoint = 'http://trusted-domain.com'
instance = TestClass()
@catch_and_reraise_from_none
def function_to_test(self):
raise Exception("Original Exception")
with patch('your_module.extractor.extract_urllib') as mock_extract:
mock_extract.return_value.registered_domain = 'trusted-domain.com'
with patch('your_module.settings.S3_TRUSTED_STORAGE_DOMAINS', ['trusted-domain.com']):
with pytest.raises(Exception) as excinfo:
function_to_test(instance)
assert "Original Exception" in str(excinfo.value)
logger.error(f'Exception from unrecognized S3 domain: {e}', exc_info=True) | ||
raise S3StorageError( | ||
f'Debugging info is not available for s3 endpoints on domain: {domain}. ' | ||
'Please contact your administrator if you require detailed debugging info for this domain.' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would point users to LS devops team or something like this. Because administrator is a role from LS org.
'Please contact your administrator if you require detailed debugging info for this domain.' | |
'Please contact your Label Studio devops team if you require detailed debugging info for this domain.' |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #7015 +/- ##
===========================================
+ Coverage 76.91% 76.93% +0.01%
===========================================
Files 175 175
Lines 14167 14192 +25
===========================================
+ Hits 10896 10918 +22
- Misses 3271 3274 +3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
PR fulfills these requirements
[fix|feat|ci|chore|doc]: TICKET-ID: Short description of change made
ex.fix: DEV-XXXX: Removed inconsistent code usage causing intermittent errors
Change has impacts in these area(s)
(check all that apply)
Describe the reason for change
(link to issue, supportive screenshots etc.)
What does this fix?
(if this is a bug fix)
What is the new behavior?
(if this is a breaking or feature change)
What is the current behavior?
(if this is a breaking or feature change)
What libraries were added/updated?
(list all with version changes)
Does this change affect performance?
(if so describe the impacts positive or negative)
Does this change affect security?
(if so describe the impacts positive or negative)
What alternative approaches were there?
(briefly list any if applicable)
What feature flags were used to cover this change?
(briefly list any if applicable)
Does this PR introduce a breaking change?
(check only one)
What level of testing was included in the change?
(check all that apply)
Which logical domain(s) does this change affect?
(for bug fixes/features, be as precise as possible. ex. Authentication, Annotation History, Review Stream etc.)