-
Notifications
You must be signed in to change notification settings - Fork 3
main to staging sync #189
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
main to staging sync #189
Conversation
…article-list-payload feat: include authors in aritcle list payload
chore(fix): slugify category URL
…ry-url Revert "chore(fix): slugify category URL"
feat: table of contents for articles
chore(fix): update requirements file
Feat/sponsored articles
chore(fix): rm padding from models
chore(fix): rm padding from models
@@ -78,4 +79,4 @@ | |||
|
|||
return instance | |||
except Exception as e: | |||
raise serializers.ValidationError(f"Error updating article: {str(e)}") | |||
raise serializers.ValidationError(f"Error updating article: {str(e)}") |
Check warning
Code scanning / CodeQL
Information exposure through an exception Medium
Stack trace information
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 6 months ago
To fix the problem, we need to ensure that detailed error information, including stack traces, is not exposed to the end user. Instead, we should log the detailed error message on the server and return a generic error message to the user. This can be achieved by modifying the exception handling in the create
and update
methods of the ArticleCreateUpdateSerializer
class.
- Import the
logging
module to enable logging of detailed error messages. - Replace the current exception handling to log the detailed error message and raise a
serializers.ValidationError
with a generic error message.
-
Copy modified line R1 -
Copy modified lines R65-R67 -
Copy modified lines R83-R85
@@ -1 +1,2 @@ | ||
import logging | ||
from rest_framework import serializers | ||
@@ -63,4 +64,5 @@ | ||
return article | ||
except Exception as e: | ||
raise serializers.ValidationError(f"Error creating article: {str(e)}") | ||
except Exception as e: | ||
logging.error(f"Error creating article: {str(e)}", exc_info=True) | ||
raise serializers.ValidationError("An error occurred while creating the article.") | ||
|
||
@@ -80,3 +82,4 @@ | ||
return instance | ||
except Exception as e: | ||
raise serializers.ValidationError(f"Error updating article: {str(e)}") | ||
except Exception as e: | ||
logging.error(f"Error updating article: {str(e)}", exc_info=True) | ||
raise serializers.ValidationError("An error occurred while updating the article.") |
No description provided.