Page MenuHomePhabricator

RESTBase/Parsoid responding with 404 in Vagrant for Main Page
Closed, ResolvedPublic

Description

After the last git-update this Monday (last one was probably on Friday or Thursday) Parsoid and/or RESTBase is no longer working properly for me in Vagrant.

I ran vagrant git-update --force without success and also ran vagrant provision but no changes were made. After that, I tried to remove /srv/restbase, /srv/parsoid and /etc/parsoid.localsettings.js and re-run vagrant provision and vagrant git-update --force. Still no luck.

srv/restbase/config.vagrant.yaml
logging: 
  level: info
  name: restbase
  streams: 
    - path: /vagrant/logs/restbase.log
      type: file
metrics: 
  type: log
num_workers: 1
services: 
  - conf: 
      cors: "*"
      default_page_size: 100
      default_project: 
        x-modules: 
          - options: 
              action: 
                apiUriTemplate: "{{'http://localhost:8080/w/api.php'}}"
                baseUriTemplate: "{{'http://{domain}:7231/{domain}/v1'}}"
              citoid: 
                host: "http://localhost:1970"
              events: 
                eventlogging_service: 
                  topic: resource_change
                  uri: "http://localhost:8085/v1/events"
              graphoid: 
                host: "http://localhost:11042"
              mathoid: 
                cache-control: "s-maxage=864000, max-age=86400"
                host: "http://localhost:10042"
              mobileapps: 
                host: "http://localhost:8888"
              parsoid: 
                host: "http://localhost:8000"
              related: 
                cache_control: "s-maxage=86400, max-age=86400"
              table: 
                backend: sqlite
                dbname: /var/lib/restbase/mw-vagrant.sqlite3
            path: projects/wmf_default.yaml
      mwapi_req: 
        body: "{{ default(request.query, {}) }}"
        headers: 
          host: "{{request.params.domain}}"
          user-agent: "{{user-agent}}"
        method: post
        uri: "http://{domain}/w/api.php"
      port: 7231
      restbase_req: 
        body: "{{request.body}}"
        headers: "{{request.headers}}"
        method: "{{request.method}}"
        query: "{{ default(request.query, {}) }}"
        uri: "http://localhost:7231/{{domain}}/v1/{+path}"
      salt: secret
      spec: 
        paths: 
          "/{domain:dev.wiki.local.wmftest.net}": 
            x-modules: 
              - options: 
                  action: 
                    apiUriTemplate: "{{'http://localhost:8080/w/api.php'}}"
                    baseUriTemplate: "{{'http://{domain}:7231/{domain}/v1'}}"
                  citoid: 
                    host: "http://localhost:1970"
                  events: 
                    eventlogging_service: 
                      topic: resource_change
                      uri: "http://localhost:8085/v1/events"
                  graphoid: 
                    host: "http://localhost:11042"
                  mathoid: 
                    cache-control: "s-maxage=864000, max-age=86400"
                    host: "http://localhost:10042"
                  mobileapps: 
                    host: "http://localhost:8888"
                  parsoid: 
                    host: "http://localhost:8000"
                  related: 
                    cache_control: "s-maxage=86400, max-age=86400"
                  table: 
                    backend: sqlite
                    dbname: /var/lib/restbase/mw-vagrant.sqlite3
                path: projects/wmf_default.yaml
          "/{domain:wikimedia.org}": 
            x-modules: 
              - options: 
                  action: 
                    apiUriTemplate: "{{'http://localhost:8080/w/api.php'}}"
                    baseUriTemplate: "{{'http://{domain}:7231/{domain}/v1'}}"
                  citoid: 
                    host: "http://localhost:1970"
                  events: 
                    eventlogging_service: 
                      topic: resource_change
                      uri: "http://localhost:8085/v1/events"
                  graphoid: 
                    host: "http://localhost:11042"
                  mathoid: 
                    cache-control: "s-maxage=864000, max-age=86400"
                    host: "http://localhost:10042"
                  mobileapps: 
                    host: "http://localhost:8888"
                  pageviews: 
                    host: "https://wikimedia.org/api/rest_v1/metrics"
                  parsoid: 
                    host: "http://localhost:8000"
                  related: 
                    cache_control: "s-maxage=86400, max-age=86400"
                  table: 
                    backend: sqlite
                    dbname: /var/lib/restbase/mw-vagrant.sqlite3
                path: projects/wikimedia.org.yaml
        title: "The RESTBase root"
        x-sub-request-filters: 
          - name: http
            options: 
              allow: 
                - pattern: "/^https?:\x5c/\x5c//"
            type: default
      user_agent: RESTBase/MW-Vagrant
      wikimedia.org: 
        x-modules: 
          - options: 
              action: 
                apiUriTemplate: "{{'http://localhost:8080/w/api.php'}}"
                baseUriTemplate: "{{'http://{domain}:7231/{domain}/v1'}}"
              citoid: 
                host: "http://localhost:1970"
              events: 
                eventlogging_service: 
                  topic: resource_change
                  uri: "http://localhost:8085/v1/events"
              graphoid: 
                host: "http://localhost:11042"
              mathoid: 
                cache-control: "s-maxage=864000, max-age=86400"
                host: "http://localhost:10042"
              mobileapps: 
                host: "http://localhost:8888"
              pageviews: 
                host: "https://wikimedia.org/api/rest_v1/metrics"
              parsoid: 
                host: "http://localhost:8000"
              related: 
                cache_control: "s-maxage=86400, max-age=86400"
              table: 
                backend: sqlite
                dbname: /var/lib/restbase/mw-vagrant.sqlite3
            path: projects/wikimedia.org.yaml
    entrypoint: 
    module: hyperswitch
    name: restbase
worker_heap_limit_mb: 150
/srv/parsoid/config.vagrant.yaml
logging: 
  level: info
  name: parsoid
  streams: 
    - path: /vagrant/logs/parsoid.log
      type: file
metrics: 
  type: log
num_workers: 1
services: 
  - conf: 
      cors: "*"
      localsettings: /etc/parsoid.localsettings.vagrant.js
      mwapi_req: 
        body: "{{ default(request.query, {}) }}"
        headers: 
          host: "{{request.params.domain}}"
          user-agent: "{{user-agent}}"
        method: post
        uri: "http://{domain}/w/api.php"
      port: 8000
      restbase_req: 
        body: "{{request.body}}"
        headers: "{{request.headers}}"
        method: "{{request.method}}"
        query: "{{ default(request.query, {}) }}"
        uri: "http://localhost:7231/{{domain}}/v1/{+path}"
      user_agent: parsoid/MW-Vagrant
    entrypoint: apiServiceWorker
    module: lib/index.js
    name: parsoid
worker_heap_limit_mb: 150
/etc/parsoid.localsettings.vagrant.js
/**
 * Parsoid web service configuration file.
 * This file is managed by Puppet.
 */
exports.setup = function( parsoidConfig ) {
    parsoidConfig.setMwApi( {
        prefix: 'localhost',
        domain: 'dev.wiki.local.wmftest.net',
        uri: 'http://localhost:8080/w/api.php',
    } );

    parsoidConfig.usePHPPreProcessor = true;
    parsoidConfig.useSelser = true;
    parsoidConfig.allowCORS = '*';

};

Using VisualEditor to edit the Main Page; from Chrome Dev Tools:

OPTIONS http://dev.wiki.local.wmftest.net:8080/api/rest_v1/transform/wikitext/to/html/Main_Page/9
404 Not Found

{"type":"https://mediawiki.org/wiki/HyperSwitch/errors/not_found#route","title":"Not found.","method":"options","uri":"/dev.wiki.local.wmftest.net/v1/transform/wikitext/to/html/Main_Page/9"}

Accessing http://dev.wiki.local.wmftest.net:8080/api/rest_v1/ the RESTBase docs appear without issue.

Event Timeline

Pchelolo subscribed.

Ha! Interesting! I can reproduce the problem only if I go to localhost:8080 and try to do a visual edit. Then the browser sends a request to dev.wiki.local.wmftest.net, it's a cross-origin request, so a preflight is sent. For some reason RESTBase responds to a preflight OPTIONS with a 404. Investigation continues.

Change 339325 had a related patch set uploaded (by Ppchelko):
Added a CSP headers filter to RESTBase config.

https://gerrit.wikimedia.org/r/339325

Ok, the reason is that we've move the CSP headers generation out into a filter and forgot to update RESTBase config in Vagrant. The above patch should take care of that and fix your problem.

Change 339325 merged by Ppchelko:
Added a CSP headers filter to RESTBase config.

https://gerrit.wikimedia.org/r/339325