-
Notifications
You must be signed in to change notification settings - Fork 2
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
Raise exception if in debug mode when uploading documents in tests #2447
base: dev
Are you sure you want to change the base?
Conversation
bd54308
to
ff77c2b
Compare
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.
Some food for thought. View full project report here.
@@ -32,6 +32,8 @@ def get(self, request): | |||
try: | |||
s3.upload_file(file_to_upload_abs_path, settings.AWS_STORAGE_BUCKET_NAME, s3_key) | |||
except Exception as e: # noqa | |||
if settings.DEBUG: |
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.
Using settings.DEBUG
here makes it harder to unit test or manually test this code in isolation because the value of settings.DEBUG
affects other Django behaviors such as showing technical error log when uncaught exceptions occur, sending admin emails, recording every SQL query executed, and many more.
Instead, consider adding a feature flag specifically for this rather than using settings.DEBUG
. More details.
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.
Looks good. Worth considering though. View full project report here.
@@ -32,6 +32,8 @@ def get(self, request): | |||
try: | |||
s3.upload_file(file_to_upload_abs_path, settings.AWS_STORAGE_BUCKET_NAME, s3_key) | |||
except Exception as e: # noqa | |||
if settings.DEBUG: |
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.
Using settings.DEBUG
here makes it harder to unit test or manually test this code in isolation because the value of settings.DEBUG
affects other Django behaviors such as showing technical error log when uncaught exceptions occur, sending admin emails, recording every SQL query executed, and many more.
Instead, consider adding a feature flag specifically for this rather than using settings.DEBUG
. More.
Aim
When in debug mode, if there is a file upload issue then raise the exception.
This should make it easier to debug exactly what failed when an upload error occurs, especially when running e2e tests in CI.