Skip to content

Conversation

@lpi-tn
Copy link
Collaborator

@lpi-tn lpi-tn commented Jan 13, 2026

This pull request introduces improved error handling for HTTP errors in the WikipediaUpdater workflow. Now, when an HTTP error occurs during document comparison, the error is logged and a corresponding entry is added to the database for better traceability.

Error handling improvements:

  • Added import of requests.exceptions to support handling HTTP errors in the workflow (wikipedia_updater.py).
  • Updated the main() function to catch requests.exceptions.HTTPError, log the error, and create an ErrorRetrieval entry in the database with details about the HTTP error (wikipedia_updater.py).

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enhances error handling in the Wikipedia updater workflow by specifically catching and logging HTTP errors that occur during document comparison operations.

Changes:

  • Added HTTP error handling to catch requests.exceptions.HTTPError during document comparison
  • Implemented database logging for HTTP errors via ErrorRetrieval entries

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +91 to +94
db_session.add(
ErrorRetrieval(
document_id=wld.id,
http_error_code=e.response.status_code,
Copy link

Copilot AI Jan 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potential AttributeError if e.response is None. The HTTPError exception doesn't guarantee that the response attribute is set. Add a guard to handle cases where e.response might be None, such as network timeouts or connection errors.

Suggested change
db_session.add(
ErrorRetrieval(
document_id=wld.id,
http_error_code=e.response.status_code,
http_error_code = e.response.status_code if e.response is not None else None
db_session.add(
ErrorRetrieval(
document_id=wld.id,
http_error_code=http_error_code,

Copilot uses AI. Check for mistakes.
Comment on lines +91 to +95
db_session.add(
ErrorRetrieval(
document_id=wld.id,
http_error_code=e.response.status_code,
error_info=f"HTTP error occurred: {str(e)} from wikipedia_updater",
Copy link

Copilot AI Jan 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message format 'HTTP error occurred: {str(e)} from wikipedia_updater' could be more informative. Consider including the URL or endpoint that failed and the specific HTTP status code in a structured format for better debugging.

Suggested change
db_session.add(
ErrorRetrieval(
document_id=wld.id,
http_error_code=e.response.status_code,
error_info=f"HTTP error occurred: {str(e)} from wikipedia_updater",
response = getattr(e, "response", None)
status_code = getattr(response, "status_code", "unknown")
request_url = getattr(response, "url", "unknown")
db_session.add(
ErrorRetrieval(
document_id=wld.id,
http_error_code=status_code,
error_info=(
f"HTTPError in wikipedia_updater | "
f"status_code={status_code} | "
f"url={request_url} | "
f"detail={e}"
),

Copilot uses AI. Check for mistakes.
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.

2 participants