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

Bad token error #176

Open
PythonCoderAS opened this issue Apr 9, 2023 · 4 comments
Open

Bad token error #176

PythonCoderAS opened this issue Apr 9, 2023 · 4 comments
Labels

Comments

@PythonCoderAS
Copy link
Contributor

While running a very long edit session (over 125k edits), the process terminated with this error:

{ badtoken: badtoken: Invalid CSRF token.
    at requestError (/mnt/nfs/labstore-secondary-tools-home/rpi2026f1/.local/lib/node_modules/wikibase-cli/node_modules/wikibase-edit/lib/request/parse_response_body.js:18:15)
    at module.exports (/mnt/nfs/labstore-secondary-tools-home/rpi2026f1/.local/lib/node_modules/wikibase-cli/node_modules/wikibase-edit/lib/request/parse_response_body.js:11:33)
    at process._tickCallback (internal/process/next_tick.js:68:7)
url: https://www.wikidata.org/w/api.php?action=wbsetdescription&format=json
response status: 200
response body: {"error":{"code":"badtoken","info":"Invalid CSRF token.","*":"See https://www.wikidata.org/w/api.php for API usage. Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/postorius/lists/m
ediawiki-api-announce.lists.wikimedia.org/> for notice of API deprecations and breaking changes."},"servedby":"mw2287"}
  name: 'badtoken',
  statusCode: 500,
  statusMessage: undefined,
  headers:
   Headers {
     [Symbol(map)]:
      [Object: null prototype] {
        date: [ 'Thu, 06 Apr 2023 14:38:20 GMT' ],
        server: [ 'mw2287.codfw.wmnet' ],
        'x-content-type-options': [ 'nosniff' ],
        'mediawiki-api-error': [ 'badtoken' ],
        'x-frame-options': [ 'DENY' ],
        'content-disposition': [ 'inline; filename=api-result.json' ],
        'cache-control': [ 'private, must-revalidate, max-age=0' ],
        vary: [ 'Accept-Encoding' ],
        'content-length': [ '343' ],
        'content-type': [ 'application/json; charset=utf-8' ],
        age: [ '2' ],
        'x-cache': [ 'cp1077 pass, cp1083 pass' ],
        'x-cache-status': [ 'pass' ],
        'server-timing': [ 'cache;desc="pass", host;desc="cp1083"' ],
        'strict-transport-security': [ 'max-age=106384710; includeSubDomains; preload' ],
        'report-to':
         [ '{ "group": "wm_nel", "max_age": 604800, "endpoints": [{ "url": "https://intake-logging.wikimedia.org/v1/events?stream=w3c.reportingapi.network_error&schema_uri=/w3c/reportingapi/network_error/1.0.0" }] }' ],
        nel:
         [ '{ "report_to": "wm_nel", "max_age": 604800, "failure_fraction": 0.05, "success_fraction": 0.0}' ],
        'set-cookie':
         [ 'WMF-Last-Access=06-Apr-2023;Path=/;HttpOnly;secure;Expires=Mon, 08 May 2023 12:00:00 GMT',
           'WMF-Last-Access-Global=06-Apr-2023;Path=/;Domain=.wikidata.org;HttpOnly;secure;Expires=Mon, 08 May 2023 12:00:00 GMT',
           'GeoIP=US:::37.75:-97.82:v4; Path=/; secure; Domain=.wikidata.org' ],
        'x-client-ip': [ '185.15.56.66' ],
        'accept-ranges': [ 'bytes' ] } },
  body:
   { error:
      { code: 'badtoken',
        info: 'Invalid CSRF token.',
        '*':
         'See https://www.wikidata.org/w/api.php for API usage. Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/postorius/lists/mediawiki-api-announce.lists.wikimedia.org/> for notice of API de
precations and breaking changes.' },
     servedby: 'mw2287' },
  url:
   'https://www.wikidata.org/w/api.php?action=wbsetdescription&format=json',
context:
   { url:
      'https://www.wikidata.org/w/api.php?action=wbsetdescription&format=json',
     body:
      { error:
         { code: 'badtoken',
           info: 'Invalid CSRF token.',
           '*':
            'See https://www.wikidata.org/w/api.php for API usage. Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/postorius/lists/mediawiki-api-announce.lists.wikimedia.org/> for notice of API
 deprecations and breaking changes.' },
        servedby: 'mw2287' } } }
  • wikibase-cli version: <!-- the latest version, right? :D > 16.3.1
  • OS version: Debian GNU/Linux 10 (buster)
@maxlath maxlath added the bug label Apr 11, 2023
maxlath added a commit to maxlath/wikibase-edit that referenced this issue Apr 11, 2023
and retry several times in case of a token error
before letting the request fail

Attempting to address maxlath/wikibase-cli#176
maxlath added a commit that referenced this issue Apr 11, 2023
@maxlath
Copy link
Owner

maxlath commented Apr 11, 2023

Hum, that's weird, it's suppose to try to get a new token when it gets this error. I tried to make the request function more resilient by retrying more times, and publish that patch in wikibase-cli v16.3.2. Hopefully that will be enough to fix the issue, but please do let me know if that happens again with the patched version.

Were you able to restart the batch session from where it crashed without too much troubles?

@PythonCoderAS
Copy link
Contributor Author

Since the batch session was about 90% complete I decided the trouble of figuring out which items were complete was too much. This batch had over 125k items, so it would be a pain to figure out.

@maxlath
Copy link
Owner

maxlath commented Apr 12, 2023

Didn't the logs just above the error tell you the last successful edit?

@PythonCoderAS
Copy link
Contributor Author

It did, but since the item list is so high, it's not an immediate priority to rerun the batch since all it was doing was setting descriptions in a language.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants