Skip to content

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

Merged
merged 22 commits into from
Nov 6, 2024
Merged

main to staging sync #189

merged 22 commits into from
Nov 6, 2024

Conversation

happychuks
Copy link
Contributor

No description provided.

2077collective and others added 22 commits October 5, 2024 13:25
…article-list-payload

feat: include authors in aritcle list payload
…ry-url

Revert "chore(fix): slugify category URL"
@@ -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
flows to this location and may be exposed to an external user.

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.

  1. Import the logging module to enable logging of detailed error messages.
  2. Replace the current exception handling to log the detailed error message and raise a serializers.ValidationError with a generic error message.
Suggested changeset 1
server/apps/research/serializers/article_serializer.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/server/apps/research/serializers/article_serializer.py b/server/apps/research/serializers/article_serializer.py
--- a/server/apps/research/serializers/article_serializer.py
+++ b/server/apps/research/serializers/article_serializer.py
@@ -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.")
EOF
@@ -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.")
Copilot is powered by AI and may make mistakes. Always verify output.
Unable to commit as this autofix suggestion is now outdated
@happychuks happychuks merged commit 7f79fbe into staging Nov 6, 2024
4 checks passed
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.

4 participants