Since we switched in huggle to new rollback token system where rollback token is retrieved in separate query, we are facing issues where token we get is randomly invalid. It work in about 90% of cases, but sometimes, the token is invalid (badtoken) and even if we fallback to previous method, the new token we get is also invalid. Bellow some examples:
Working case:
token
OUT https://en.wikipedia.org/w/api.php?action=query&meta=tokens&type=watch%7Cpatrol%7Crollback&rawcontinue=1&format=xml
IN <?xml version="1.0"?><api><query><tokens watchtoken="e11b5b5346ce0a744f0e31278a7cf7e0545f2aee+\" patroltoken="5789d00efc3dd2a7ca4c586cd10348ad545f2aee+\" rollbacktoken="d228eb077234bf71dbf98a015b989abf545f2aee+\" /></query></api>
reverts
OUT https://en.wikipedia.org/w/api.php?action=rollback&format=xml&assert=user title=Jes%C3%BAs%20Murillo%20Karam&token=d228eb077234bf71dbf98a015b989abf545f2aee%2B%5C&watchlist=nochange&user=198.208.159.18&summary=Reverted%20edits%20by%20%5B%5BSpecial%3AContributions%2F198.208.159.18%7C198.208.159.18%5D%5D%20%28%5B%5BUser%20talk%3A198.208.159.18%7Ctalk%5D%5D%29%20%28%5B%5BWP%3AHG%7CHG%5D%5D%29
IN <?xml version="1.0"?><api><rollback title="Jesús Murillo Karam" pageid="10579766" summary="Reverted edits by [[Special:Contributions/198.208.159.18|198.208.159.18]] ([[User talk:198.208.159.18|talk]]) ([[WP:HG|HG]])" revid="633067555" old_revid="633067544" last_revid="630729747" /></api>
BUG:
token
OUT https://en.wikipedia.org/w/api.php?action=query&meta=tokens&type=watch%7Cpatrol%7Crollback&rawcontinue=1&format=xml
IN <?xml version="1.0"?><api><query><tokens watchtoken="2e6847e19ae3ecf0da33c7aa2bb409ec545fb203+\" patroltoken="088745a10c40d65413b94e483c0a050e545fb203+\" rollbacktoken="3de1b08c3de9a4fe792182e8b2bf5d67545fb203+\" /></query></api>
reverts
OUT https://en.wikipedia.org/w/api.php?action=rollback&format=xml&assert=user title=List%20of%20college%20athletic%20programs%20in%20California&token=3de1b08c3de9a4fe792182e8b2bf5d67545fb203%2B%5C&watchlist=nochange&user=216.160.129.240&summary=Reverted%20edits%20by%20%5B%5BSpecial%3AContributions%2F216.160.129.240%7C216.160.129.240%5D%5D%20%28%5B%5BUser%20talk%3A216.160.129.240%7Ctalk%5D%5D%29%20%28%5B%5BWP%3AHG%7CHG%5D%5D%29
IN <?xml version="1.0"?><api servedby="mw1146"><error code="badtoken" info="Invalid token" xml:space="preserve">See https://en.wikipedia.org/w/api.php for API usage</error></api>
then huggle try to fix it on next revert falling back to:
OUT https://en.wikipedia.org/w/api.php?action=query&prop=revisions&rvprop=ids%7Cuser%7Ctimestamp%7Ccomment&rvlimit=1&rvtoken=rollback&rvstartid=633119006&rvdiffto=prev&titles=Economy%20of%20Milan&rawcontinue=1&format=xml
response from mediawiki with new token
IN <?xml version="1.0"?><api><query-continue><revisions rvcontinue="633113435" /></query-continue><warnings><revisions xml:space="preserve">The rvtoken parameter has been deprecated.</revisions></warnings><query><pages><page pageid="24724090" ns="0" title="Economy of Milan"><revisions><rev revid="633119006" parentid="633113435" user="Sushi242" timestamp="2014-11-09T18:27:49Z" comment="Starting to add edits from talk page and word document into the article main space, includes some missing citations" rollbacktoken="df2624df67619c7b916774002ac79bab545fb226+\"><d.....
huggle does a next revert using this new token
OUT https://en.wikipedia.org/w/api.php?action=rollback&format=xml&assert=user title=Tipi&token=df2624df67619c7b916774002ac79bab545fb226%2B%5C&watchlist=nochange&user=73.18.143.85&summary=Reverted%20edits%20by%20%5B%5BSpecial%3AContributions%2F73.18.143.85%7C73.18.143.85%5D%5D%20%28%5B%5BUser%20talk%3A73.18.143.85%7Ctalk%5D%5D%29%20%28%5B%5BWP%3AHG%7CHG%5D%5D%29
IT FAILS
IN <?xml version="1.0"?><api servedby="mw1199"><error code="badtoken" info="Invalid token" xml:space="preserve">See https://en.wikipedia.org/w/api.php for API usage</error></api>
Notes:
This bug happens only when high traffic is on wiki, especially in peak hours when lot of vandals are being reverted (15+ reverts per minute). It can be reproduced only on wikimedia installation (for example english wikipedia) not custom mw installs, and it happens only rarely (1 from 20 sessions). I believe it is related to some api caching, memory caches or buffer overwrites.
Version: 1.25-git
Severity: normal