Page MenuHomePhabricator

RESTBase Error 'SiteInfo is unavailable'
Closed, ResolvedPublic

Description

I just installed RESTBase on my server following the instructions from https://www.mediawiki.org/wiki/RESTBase/Installation
When testing it it was working except for the /page/* links. They return:

{
"type":"https://mediawiki.org/wiki/HyperSwitch/errors/server_error",
"title":"Site info fetch failed.",
"method":"get",
"detail":"SiteInfo is unavailable for wiki.MYDOMAIN.XX",
"uri":"/wiki.MYDOMAIN.XX/v1/page/html/PAGENAME"
}

My configuration is not special, just the example with the domain's changed where needed.
I checked the Parsoid logs but they show noting from these tests.
The command line where RESTBase is running shows:

{"name":"restbase","hostname":"MYSERVER","pid":23279,"level":50,"message":"500: server_error","res":{"name":"HTTPError","message":"500: server_error","status":500,"body":{"type":"server_error","title":"Site info fetch failed.","detail":"SiteInfo is unavailable for wiki.MYDOMAIN.XX"},"headers":{"access-control-allow-origin":"*","access-control-allow-methods":"GET,HEAD","access-control-allow-headers":"accept, content-type, content-length, cache-control, accept-language, api-user-agent, if-match, if-modified-since, if-none-match, dnt, accept-encoding","access-control-expose-headers":"etag","x-content-type-options":"nosniff","x-frame-options":"SAMEORIGIN","referrer-policy":"origin-when-cross-origin","x-xss-protection":"1; mode=block","content-security-policy":"default-src 'none'; frame-ancestors 'none'","x-content-security-policy":"default-src 'none'; frame-ancestors 'none'","x-webkit-csp":"default-src 'none'; frame-ancestors 'none'","cache-control":"private, max-age=0, s-maxage=0, must-revalidate","x-request-id":"a8e2f306-5d07-11e8-b3bb-22c501a0c228","server":"MYSERVER"}},"stack":"HTTPError: 500: server_error\n    at Request._siteInfoCache.(anonymous function)._doRequest.catch (/home/ubuntu/cxserver/restbase/sys/action.js:324:23)\n    at Request.tryCatcher (/home/ubuntu/cxserver/restbase/node_modules/bluebird/js/release/util.js:16:23)\n    at Promise._settlePromiseFromHandler (/home/ubuntu/cxserver/restbase/node_modules/bluebird/js/release/promise.js:512:31)\n    at Promise._settlePromise (/home/ubuntu/cxserver/restbase/node_modules/bluebird/js/release/promise.js:569:18)\n    at Promise._settlePromise0 (/home/ubuntu/cxserver/restbase/node_modules/bluebird/js/release/promise.js:614:10)\n    at Promise._settlePromises (/home/ubuntu/cxserver/restbase/node_modules/bluebird/js/release/promise.js:689:18)\n    at Async._drainQueue (/home/ubuntu/cxserver/restbase/node_modules/bluebird/js/release/async.js:133:16)\n    at Async._drainQueues (/home/ubuntu/cxserver/restbase/node_modules/bluebird/js/release/async.js:143:10)\n    at Immediate.Async.drainQueues (/home/ubuntu/cxserver/restbase/node_modules/bluebird/js/release/async.js:17:14)\n    at runCallback (timers.js:810:20)\n    at tryOnImmediate (timers.js:768:5)\n    at processImmediate [as _immediateCallback] (timers.js:745:5)","latency":173,"root_req":{"method":"get","uri":"/wiki.suhasselt.be/v1/page/lint/Praesidium","headers":{"user-agent":"Mozilla/5.0 (X11; Linux x86_64; rv:61.0) Gecko/20100101 Firefox/61.0","x-client-ip":"::ffff:xxx.xxx.xxx.xxx","x-forwarded-for":"::ffff:xxx.xxx.xxx.xxx","x-request-id":"a8e2f306-5d07-11e8-b3bb-22c501a0c228","x-request-class":"external"}},"request_id":"a8e2f306-5d07-11e8-b3bb-22c501a0c228","levelPath":"error/request","msg":"500: server_error","time":"2018-05-21T15:00:11.613Z","v":0}

Searching for a solution did not show any good results. Except for https://www.mediawiki.org/wiki/Topic:Ty9zrnylsr4bpdw1
This page said I should file a bugreport for this.
So how can I solve this or is this a bug?

Other info:
MediaWiki: 1.29.1
PHP: 7.0.30-0ubuntu0.16.04.1 (apache2handler)
NodeJS: v8.11.2
RESTBase Tested: v0.18.1 (Download from GitHub) and Current Master (21/05/2018)

Event Timeline

mobrovac subscribed.

SiteInfo is unavailable for wiki.MYDOMAIN.XX

The wiki you are configuring RESTBase for needs to exist. In other words, the RESTBase configuration needs to be for a domain that has a working MediaWiki instance set up. Could you provide your config.yaml?

I anonymized the data and settings, but there is an existing private wiki behind the real domain. And that is working fine. The Visual editor is working with Parsoid so there should not be a problem there.

Here is my config.yaml (also anonymized):

# RESTBase config for small wiki installs
#
# - sqlite backend
# - parsoid at http://localhost:8142
# - wiki at http://localhost/w/api.php
# 
# Quick setup:
# - npm install
#   If you see errors about sqlite, you might have to `apt-get install
#   libsqlite3-dev`.
# - cp config.example.yaml config.yaml
# - double-check and possibly modify lines marked with XXX, then start restbase with
#
#   node server
#
# - If all went well, http://localhost:7231/localhost/v1/page/html/Main_Page
# should show your wiki's [[Main Page]].

services:
  - name: restbase
    module: hyperswitch
    conf: 
      port: 7231
      salt: secret
      default_page_size: 125
      user_agent: RESTBase
      ui_name: RESTBase
      ui_url: https://www.mediawiki.org/wiki/RESTBase
      ui_title: RESTBase docs
      spec:
        x-request-filters:
          - path: lib/security_response_header_filter.js
        x-sub-request-filters:
          - type: default
            name: http
            options:
              allow:
                - pattern: http://wiki.MYDOMAIN.XX/api.php
                  forward_headers: true
                - pattern: http://wiki.MYDOMAIN.XX:8142
                  forward_headers: true
                - pattern: /^https?:\/\//
        paths:
          /{domain:wiki.MYDOMAIN.XX}:
            x-modules:
              - path: projects/example.yaml
                options:
                  action:
                    # XXX Check API URL!
                    apiUriTemplate: http://wiki.MYDOMAIN.XX/api.php
                    # XXX Check the base RESTBase URI
                    baseUriTemplate: "{{'http://{domain}:7231/{domain}/v1'}}"
                  parsoid:
                    # XXX Check Parsoid URL!
                    host: http://wiki.MYDOMAIN.XX:8142
                  table:
                    backend: sqlite
                    dbname: db.sqlite3
                    pool_idle_timeout: 20000
                    retry_delay: 250
                    retry_limit: 10
                    show_sql: false
                  mobileapps:
                    host: http://appservice.wmflabs.org
                  purged_cache_control: s-maxage=0, max-age=86400
                  purged_cache_control_client_cache: s-maxage=0, max-age=300

# Finally, a standard service-runner config.
info:
  name: restbase

logging:
  name: restbase
  level: info

I checked the api.php path and is correct.
I also checked the Parsoid path and this is also fine.
I also installed RESTBase on my local machine and configured it the same and get the same error.

I want to install RESTBase for Extension:ContentTranslation with requires cxserver with requires RESTBase.

Ah, it's a private wiki. Unfortunately, RESTBase doesn't support private wikis currently, cf. T88016: Handle read access for private wikis.

Does this also applies to wiki's that are private, but are publicly accessible? (I don't know if I used the word 'private wiki' correct)
Because this wiki is publicly readable. And can be modified by users who have account.
The post you linked talks about security for read requests.

I think I need to reopen this topic to get a response...
(see previous reply)

Is the wiki readable by anonymous users? If it's not, then my answer still stands. If not, the siteinfo call might be failing because the link between RESTBase and MW is misconfigured. Namely, apiUriTemplate: http://wiki.MYDOMAIN.XX/api.php might need some tweaking. Is that URL reachable from the machine powering RESTBase?

Due to an old issue with configuring this the right config should be:

apiUriTemplate: "{{'http://wiki.MYDOMAIN.XX/api.php'}}"
Ralpha9 claimed this task.

I fixed the problem. The api URL (apiUriTemplate) was correct but was set to http:// and not https://.
And my server does not allow http connections. It will redirect them to the https page.
But RESTBase doesn't follow redirects (301 Moved Permanently) it seems.
Such a small thing.
Thanks for the help!

Vvjjkkii renamed this task from RESTBase Error 'SiteInfo is unavailable' to ljcaaaaaaa.Jul 1 2018, 1:09 AM
Vvjjkkii reopened this task as Open.
Vvjjkkii removed Ralpha9 as the assignee of this task.
Vvjjkkii raised the priority of this task from Medium to High.
Vvjjkkii updated the task description. (Show Details)
Vvjjkkii removed a subscriber: Aklapper.
mobrovac renamed this task from ljcaaaaaaa to RESTBase Error 'SiteInfo is unavailable'.Jul 1 2018, 11:02 AM
mobrovac closed this task as Resolved.
mobrovac assigned this task to Ralpha9.
mobrovac lowered the priority of this task from High to Medium.
mobrovac updated the task description. (Show Details)