#5140 Wiki editing via API failing when captcha has to be solved
Closed: Fixed None Opened 8 years ago by adamwill.

Well this is odd. My 'wikitcms' project has a bit of code for handling the captcha system we have on the wiki. It's been working fine for years.

Suddenly, it seems like it's not working any more. When I try and make an edit that requires a captcha solve with wikitcms, it fails.

I have verified six ways from Sunday that wikitcms is parsing the question correctly, producing the correct answer, and sending the correct params back to mwclient - 'captchaid' and 'captchaword'. I have even stuck a couple of log lines in mwclient to check that 'captchaid' and 'captchaword' are in the params it sends along to the mw API, and they are.

I have tried with old versions of both wikitcms and mwclient - old versions I know were working, because we got validation events for the last couple of months - and no dice. So something must have changed outside of wikitcms and mwclient, and I wanna say it's on the server end, but I don't see any huge changes in https://fedoraproject.org/wiki/Special:Version , and I get the same errors from both stg and prod wiki.

So...what the hell gives?!

This is a major issue because relval can't create release validation pages ATM.


here's a simple test script:

{{{

!/usr/bin/python

import logging
import wikitcms.wiki
import wikitcms.page

logger = logging.getLogger(name)
logging.basicConfig(level=logging.DEBUG)

site = wikitcms.wiki.Wiki(('https', 'stg.fedoraproject.org'), '/w/')
site.force_login = False
page = wikitcms.page.Page(site, 'Test Results:Foo')
page.save('https://www.foo.com')
}}}

That should work, instead it doesn't. wikitcms tries to save the page, gets an mwclient EditError with the captcha, solves it, sends another save request with the captchaid and captchaword, and mwclient raises another EditError with another captcha to solve. I do not know why.

If you run the test script with latest git master wikitcms you get some debug output showing that wikitcms hits its captcha solving code, finds the captcha, solves it, and sends the second request to mwclient.

so here's some weirdness: a similar test script works just fine if I'm logged in - I made it save a random URL to trigger the captcha every time, and checked it really was hitting a captcha, and the page save still works just fine. So I suspect the reason the test script fails reliably is that mwclient/wikitcms don't preserve the session across requests if you're not logged in.

But! Event creation from my fedmsg consumer is still often failing due to captcha errors, and I just cannot figure out why. The consumer does log in to the wiki. I can run the test-script-with-login on the same box that does the event creations and it works no trouble. I can create events manually (which winds up on basically the same codepath as the consumer) and it seems to work fine. So I just cannot figure out why the consumer has issues.

Anyhow, if we can't figure out the problem, can we blunt force it? Could you please captcha whitelist both my IP - 184.71.189.90 - and the IP range for the QA network in phx2, so if we move event creation into infra it will also be whitelisted? Thanks.

OK, so puiterwijk changed the wiki configuration such that the bots should not encounter captchas any more when creating events, effectively solving the problem. I'll re-open this if I still somehow have issues.

Login to comment on this ticket.

Metadata