Skip to content
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

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

kevincarrogan
Copy link
Contributor

@kevincarrogan kevincarrogan commented Mar 7, 2025

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.

@kevincarrogan kevincarrogan marked this pull request as ready for review March 10, 2025 10:49
@kevincarrogan kevincarrogan force-pushed the fix-e2e-uploading-files branch from bd54308 to ff77c2b Compare March 10, 2025 10:49
Copy link
Contributor

@code-review-doctor code-review-doctor bot left a 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:
Copy link
Contributor

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.

Copy link
Contributor

@code-review-doctor code-review-doctor bot left a 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:
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant