Skip to content

fix(api): improve error handling and add timeouts to edit_page endpoint#98

Open
Avalanche-ag wants to merge 1 commit into
indictechcom:masterfrom
Avalanche-ag:fix-edit-page-errors
Open

fix(api): improve error handling and add timeouts to edit_page endpoint#98
Avalanche-ag wants to merge 1 commit into
indictechcom:masterfrom
Avalanche-ag:fix-edit-page-errors

Conversation

@Avalanche-ag
Copy link
Copy Markdown

Problem

The current /api/edit_page endpoint does not do input validation and assumes that targetUrl is always in the correct format. If it is malformed or missing, re.findall and the regex matcher crash the backend with an IndexError or TypeError. Furthermore, the requests library calls are made with no timeout, risking the server hanging indefinitely if the wikimedia API is temporarily unreachable.

Solution

This PR hardens the /api/edit_page code natively.

  • Added strict presence and format validation to requestURL and content.
  • Implemented timeout=10 on target API fetch and pushes.
  • Handles missing token retrieval gracefully instead of unhandled downstream exceptions.

Related Tasks

Adresses the Backend Error Handling & Observability micro-task goals outline in T415715.

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