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

Fix: Prevents 414 request-uri too long for import_articles_by_title by using a POST request #6212

Merged

Conversation

empty-codes
Copy link
Contributor

@empty-codes empty-codes commented Feb 25, 2025

What this PR does

Fixes 414 request-uri too long for import_articles_by_title by using a POST request instead of a GET request:

  • Adds kn.wikipedia.org to list of stubbed wiki validations
  • Adds meta method in wiki_api to prevent:
      Failure/Error:
       def query(query_parameters = {}, http_method: :get)
         mediawiki('query', query_parameters.merge(http_method: http_method))

     ArgumentError:
       unknown keyword: :meta
     # ./lib/wiki_api.rb:23:in `query'
     # ./app/models/wiki.rb:188:in `ensure_wiki_exists'

The former code site_info = WikiApi.new(self).query(meta: :siteinfo) in wiki.rb's ensure_wiki_exists method worked because the query method is a general entry point for all API requests and the mediawiki gem automatically processes meta requests since it is a valid method. My change to wiki_api's query method however bypasses the gem's automatic routing of meta: :siteinfo causing the error.

The solution was implementing a meta method in the WikiApi class that directly calls the meta method from the mediawiki-api gem.

  • Adds a test that confirms 414 request-uri too long no longer occurs and a new vcr-cassette some_article_titles.yml

Screenshots

Before:
image

After:
image
image

…a POST request instead of a GET request:

- Adds kn.wikipedia.org to list of stubbed wiki validations
- Adds `meta` method in wiki_api to prevent:
     ArgumentError:
       unknown keyword: :meta as `query(meta: :siteinfo)` worked because the MediaWiki gem automatically processes `meta` requests since it is a valid method but my change to query bypasses the gem's automatic routing of `meta: :siteinfo`.
- Adds a test that confirms 414 request-uri too long no longer occurs and a new vcr-cassette some_article_titles.yml
@ragesoss
Copy link
Member

This looks great. I can merge it if the tests pass.

@ragesoss ragesoss merged commit 34d4669 into WikiEducationFoundation:master Feb 25, 2025
1 check passed
Copy link

sentry-io bot commented Feb 25, 2025

Suspect Issues

This pull request was deployed and Sentry observed the following issues:

  • ‼️ MediawikiApi::HttpError: unexpected HTTP response (429) Sidekiq/CourseDataUpdateWorker View Issue

Did you find this useful? React with a 👍 or 👎

@empty-codes
Copy link
Contributor Author

Suspect Issues

This pull request was deployed and Sentry observed the following issues:

  • ‼️ MediawikiApi::HttpError: unexpected HTTP response (429) Sidekiq/CourseDataUpdateWorker View Issue

Did you find this useful? React with a 👍 or 👎

I just checked and it's the same usual 429 error that occurs so it wasn't caused by this. I guess sentry is notifying because it's the first occurence after I changed query

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