I am using the latest RESTBase from git with MediaWiki 1.39.3. If I sent a page/html/SOMETITLE request to RESTBase, I can see from the logs that it is calling MYDOMAIN/w/rest.php/MYDOMAIN/v3/page/pagebundle/SOMETITLE/VERSIONID. However, this returns a 404 error saying that the requested relative path did not match any known handler. Any thoughts? Am I missing a configuration setting somewhere?
Talk:RESTBase/Installation
Appearance
You have to include the Parsoid "extension" in localsettings.php:
wfLoadExtension( 'Parsoid', "$IP/vendor/wikimedia/parsoid/extension.json" );
At least that's what I had to add to make it work on my installation, with this exact problem
That worked. Thanks.
I've just moved my wiki to a new server. If I browse to /api/rest_v1/ I get the error Failed to load API definition with a message saying "Fetch error, undefined /MYWIKIDOMAIN/v1/?spec". Browsing to MYWIKIDOMAIN/v1/?spec produces a 404 error. It should be going to MYWIKIDOMAIN/api/rest_v1/?spec which returns the information that should appear on the page. I presume there is something wrong with my configuration but I can't figure out what. Any ideas?
Ignore this. I spotted the configuration step I missed. It is working now.
may i ask what did you do to solve this? I went through the steps and I cannot find which step I missed.
I just ran into the same problem - can you possibly point out how you solved it? @Prh47bridge
@ArchEcho Could you solve this on your own?
@Lifeaddict unfortunately no. I ended up with a fresh install of the newer version with the visualeditor stuff included and moved everything over.
MediaWiki | 1.35.5 |
Server | Windows 2016 |
Web Server | IIS |
DataBase | MariaDB 10.6.7 |
PHP | 7.4.13 |
Extensions | 1.35 rel |
I am not seeing anywhere how to set this configuration up when using IIS.
Please assist as I would like to get RESTBase and Parsoid communicating over HTTPS.
I have a mediawiki 1.35 on RHEL 8 installation. I installed RESTBase and when I run the test command I get:
$ curl http://127.0.0.1:7231/wiki-surveyppp.app.jandenul.com/rest.php/v1/page/Main_Page
{"type":"https://mediawiki.org/wiki/HyperSwitch/errors/not_found#route","title":"Not found.","method":"get","uri":"/wiki-surveyppp.app.jandenul.com/rest.php/v1/page/Main_Page"}
On the server side I get
{"name":"restbase","hostname":"vm-mwsvdsppp01.jandenul.com","pid":2357,"level":30,"levelPath":"info/service-runner","msg":"master(2357) initializing 2 workers","time":"2021-03-24T16:55:08.128Z","v":0}
{"name":"restbase","hostname":"vm-mwsvdsppp01.jandenul.com","pid":2381,"level":50,"levelPath":"error/metrics","msg":"No such metrics client: 'undefined'","time":"2021-03-24T16:55:08.691Z","v":0}
{"name":"restbase","hostname":"vm-mwsvdsppp01.jandenul.com","pid":2381,"level":40,"levelPath":"warn/startup","msg":"listening on *:7231","time":"2021-03-24T16:55:09.634Z","v":0}
{"name":"restbase","hostname":"vm-mwsvdsppp01.jandenul.com","pid":2398,"level":50,"levelPath":"error/metrics","msg":"No such metrics client: 'undefined'","time":"2021-03-24T16:55:09.908Z","v":0}
{"name":"restbase","hostname":"vm-mwsvdsppp01.jandenul.com","pid":2398,"level":40,"levelPath":"warn/startup","msg":"listening on *:7231","time":"2021-03-24T16:55:10.376Z","v":0}
{"name":"restbase","hostname":"vm-mwsvdsppp01.jandenul.com","pid":2357,"level":40,"levelPath":"warn/service-runner","msg":"startup finished","time":"2021-03-24T16:55:10.376Z","v":0}
{
"name": "restbase",
"hostname": "vm-mwsvdsppp01.jandenul.com",
"pid": 2381,
"level": 20,
"message": "404: not_found#route",
"res": {
"status": 404,
"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": "ba598da0-8cc1-11eb-808c-d7fe3ae661f9",
"server": "vm-mwsvdsppp01.jandenul.com"
}
},
"stack": "HTTPError: 404: not_found#route
at HyperSwitch._request (/usr/RESTBase/node_modules/hyperswitch/lib/hyperswitch.js:270:19)
at _createFilteredHandler (/usr/RESTBase/node_modules/hyperswitch/lib/hyperswitch.js:172:26)
at tryCatcher (/usr/RESTBase/node_modules/bluebird/js/release/util.js:16:23)
at /usr/RESTBase/node_modules/bluebird/js/release/method.js:15:34
at handlerWrapper (/usr/RESTBase/node_modules/hyperswitch/lib/hyperswitch.js:424:37)
at next (/usr/RESTBase/node_modules/hyperswitch/lib/hyperswitch.js:410:42)
at Object.normalizeHeaders [as filter] (/usr/RESTBase/lib/normalize_headers_filter.js:11:12)
at handlerWrapper (/usr/RESTBase/node_modules/hyperswitch/lib/hyperswitch.js:422:27)
at next (/usr/RESTBase/node_modules/hyperswitch/lib/hyperswitch.js:410:42)
at Object.addCSPHeaders [as filter] (/usr/RESTBase/lib/security_response_header_filter.js:61:22)
at handlerWrapper (/usr/RESTBase/node_modules/hyperswitch/lib/hyperswitch.js:422:27)
at /usr/RESTBase/node_modules/hyperswitch/lib/hyperswitch.js:428:28
at HyperSwitch._filteredRequest (/usr/RESTBase/node_modules/hyperswitch/lib/hyperswitch.js:173:19)
at HyperSwitch.request (/usr/RESTBase/node_modules/hyperswitch/lib/hyperswitch.js:162:21)
at parsePOST.catchThrow.then (/usr/RESTBase/node_modules/hyperswitch/lib/server.js:351:27)
at tryCatcher (/usr/RESTBase/node_modules/bluebird/js/release/util.js:16:23)",
"latency": 3,
"root_req": {
"method": "get",
"uri": "/wiki-surveyppp.app.jandenul.com/rest.php/v1/page/Main_Page",
"headers": {
"user-agent": "curl/7.61.1",
"x-client-ip": "::ffff:127.0.0.1",
"x-forwarded-for": "::ffff:127.0.0.1",
"x-request-id": "ba598da0-8cc1-11eb-808c-d7fe3ae661f9",
"x-request-class": "internal"
}
},
"request_id": "ba598da0-8cc1-11eb-808c-d7fe3ae661f9",
"levelPath": "debug/request",
"msg": "404: not_found#route",
"time": "2021-03-24T16:55:24.797Z",
"v": 0
}
But when I put http://wiki-surveyppp.app.jandenul.com/rest.php/v1/page/Main_Page in my browser I have a correct (json) reply
I'm having the same problem. Did you ever manage to solve this?
Hey folks
After some hair loss and much poking in the dark I got my RESTBase partially running. As stated in the title, I can access the RESTBase via curl and browser and I can get title information about a page with /page/title/Hauptseite (german wiki obviously). Alas, when I try to get content with /page/html/Hauptseite I get a 404:
{ "type": "https://mediawiki.org/wiki/HyperSwitch/errors/not_found", "title": "Not found.", "method": "get", "uri": "/www.mywiki.de/v1/page/html/Hauptseite" }
as opposed to /page/title/Hauptseite
where I get
{ "items": [ { "title": "Hauptseite", "page_id": 11, "rev": 1319, "tid": "7a70c820-7d1c-11eb-9913-fb7beb5297c0", "namespace": 0, "user_id": 12, "user_text": "Anon", "timestamp": "2021-01-26T15:50:46Z", "comment": "", "tags": [ "visualeditor-wikitext" ], "restrictions": [], "page_language": "de", "redirect": false } ] }
Any pointers where I could search for my mistake?
System is:
- MW 1.35
- PHP 7.4
- Node: v10.19.0
What might be of importance: the apache redirects ALL requests to port 80 to port 443 (so all http traffic will be redirected to https). Therefore I used the following in my config.yaml:
- apiUriTemplate: https://www.mywiki.de/w/api.php
- parsoidHost: https://www.mywiki.de/w/rest.php
Oh, and https://www.mywiki.de/w/rest.php/v1/page/Hauptseite
works just fine.
Any help appreciated, thanks in advance!
Posting the cause of my error here in case someone else has the same problem:
I installed RESTBase on a 1.35 wiki w/o VisualEditor, b/c I wanted to see RESTBase running, before tackling VE. But on a normal wiki, parsoid is not loaded. So if you run in the aforementioned problem, either install and activate VisualEditor or add the following to your LocalSettings.php
:
wfLoadExtension( 'Parsoid', 'vendor/wikimedia/parsoid/extension.json' );
This post was hidden by Oetterer (history)
I keep getting this java.lang.AssertionError from my cassandra server. I tried to search for an answer but what I found, which was not specific to restbase, didn't work.
Has anyone encountered this java.lang.AssertionError or has any idea why I might be getting this?
This happens when I try to Get myrestserver:7231/mysite/v1/page/html/Main_Page
I can Get /page/title/Main_Page
But the error seems to be when I Get /page/html/{title}
{"name":"restbase","hostname":"myhost","pid":3711,"level":10,"message":"Connection","info":"Sent stream #1 to 3.234.XXX.XXX:9142","levelPath":"trace/table/cassandra/driver","msg":"Connection","time":"2020-11-11T10:24:37.761Z","v":0}
{"name":"restbase","hostname":"myhost","pid":3728,"level":10,"message":"Connection","info":"Received frame #1 from 3.234.XXX.XXX:9142","levelPath":"trace/table/cassandra/driver","msg":"Connection","time":"2020-11-11T10:24:37.816Z","v":0}
{"name":"restbase","hostname":"myhost","pid":3728,"level":30,"message":"HostConnectionPool","info":"Connection to 3.234.XXX.XXX:9142 opened successfully","levelPath":"info/table/cassandra/driver","msg":"HostConnectionPool","time":"2020-11-11T10:24:37.817Z","v":0}
{"name":"restbase","hostname":"myhost","pid":3728,"level":30,"message":"HostConnectionPool","info":"Connection pool to host 3.234.XXX.XXX:9142 created with 1 connection(s)","levelPath":"info/table/cassandra/driver","msg":"HostConnectionPool","time":"2020-11-11T10:24:37.817Z","v":0}
{"name":"restbase","hostname":"myhost","pid":3728,"level":10,"message":"Connection","info":"Received frame #1 from 3.234.XXX.XXX:9142","levelPath":"trace/table/cassandra/driver","msg":"Connection","time":"2020-11-11T10:24:37.817Z","v":0}
{"name":"restbase","hostname":"myhost","pid":3728,"level":30,"message":"HostConnectionPool","info":"Connection to 3.234.XXX.XXX:9142 opened successfully","levelPath":"info/table/cassandra/driver","msg":"HostConnectionPool","time":"2020-11-11T10:24:37.817Z","v":0}
{"name":"restbase","hostname":"myhost","pid":3728,"level":30,"message":"HostConnectionPool","info":"Connection pool to host 3.234.XXX.XXX:9142 created with 1 connection(s)","levelPath":"info/table/cassandra/driver","msg":"HostConnectionPool","time":"2020-11-11T10:24:37.817Z","v":0}
{ ResponseError: java.lang.AssertionError
at FrameReader.readError (/var/www/html/node_modules/cassandra-driver/lib/readers.js:326:15)
at Parser.parseBody (/var/www/html/node_modules/cassandra-driver/lib/streams.js:194:27)
at Parser._transform (/var/www/html/node_modules/cassandra-driver/lib/streams.js:137:10)
at Parser.Transform._read (_stream_transform.js:190:10)
at Parser.Transform._write (_stream_transform.js:178:12)
at doWrite (_stream_writable.js:415:12)
at writeOrBuffer (_stream_writable.js:399:5)
at Parser.Writable.write (_stream_writable.js:299:11)
at Protocol.ondata (_stream_readable.js:710:20)
at Protocol.emit (events.js:198:13)
at addChunk (_stream_readable.js:288:12)
at readableAddChunk (_stream_readable.js:269:11)
at Protocol.Readable.push (_stream_readable.js:224:10)
at Protocol.Transform.push (_stream_transform.js:151:32)
at Protocol.readItems (/var/www/html/node_modules/cassandra-driver/lib/streams.js:109:10)
at Protocol._transform (/var/www/html/node_modules/cassandra-driver/lib/streams.js:32:10)
name: 'ResponseError',
info: 'Represents an error message from the server',
message: 'java.lang.AssertionError',
code: 0 }
I can't get RESTBase to work using Amazon Keyspaces, I think I have followed the AWS instructions correctly but don't see why it is not working.
I think the following should be correct? (rest of the yaml file should be correct as it works with sqlite)
/table:
x-modules:
- name: restbase-mod-table-cassandra
version: 1.0.0
type: npm
options:
conf:
hosts: [cassandra.us-east-1.amazonaws.com]
keyspace: myAWSkeyspace
username: myAWSkeyspaceUsername
password: myAWSkeyspacePassword
localDc: us-east-1
datacenters:
- us-east-1
tls:
ca:
- /path/to/cert/AmazonRootCA1.pem
storage_groups:
- name: default.group.local
domains: /./
if I try to debug this is what I get, I can't figure out this options.log is not a function error. It doesn't error out if I comment
options.log(level, {
message,
info
});
in file /path/to/restbase/node_modules/restbase-mod-table-cassandra/lib/index.js, line 107.
Is that something I need to configure to the yaml config file?!
{
"name":"restbase",
"hostname":"XXXXXX",
"pid":65032,
"level":60,
"err":{"message":"options.log is not a function",
"name":"TypeError",
"stack":"TypeError: options.log is not a function\n
at Client.client.on (/path/to/restbase/node_modules/restbase-mod-table-cassandra/lib/index.js:107:17)\n
at Client.emit (events.js:198:13)\n
at Client.log (/path/to/restbase/node_modules/cassandra-driver/lib/utils.js:99:8)\n
at Client._connectCb (/path/to/restbase/node_modules/cassandra-driver/lib/client.js:406:8)\n
at handlerWrapper (/path/to/restbase/node_modules/cassandra-driver/lib/utils.js:416:13)\n
at tryCatcher (/path/to/restbase/node_modules/bluebird/js/release/util.js:16:23)\n
at Promise.fromNode.Promise.fromCallback (/path/to/restbase/node_modules/bluebird/js/release/promise.js:209:30)\n
at Client.promiseWrapper (/path/to/restbase/node_modules/cassandra-driver/lib/utils.js:415:10)\n
at Client.connect (/path/to/restbase/node_modules/cassandra-driver/lib/client.js:384:31)\n
at makeClient (/path/to/restbase/node_modules/restbase-mod-table-cassandra/lib/index.js:113:19)\n
at RBCassandra.setup (/path/to/restbase/node_modules/restbase-mod-table-cassandra/index.js:210:16)\n
at makeRBCassandra (/path/to/restbase/node_modules/restbase-mod-table-cassandra/index.js:226:15)\n
at Router._loadModule (/path/to/restbase/node_modules/hyperswitch/lib/router.js:272:26)\n
at P.each (/path/to/restbase/node_modules/hyperswitch/lib/router.js:298:25)\n
at tryCatcher (/path/to/restbase/node_modules/bluebird/js/release/util.js:16:23)\n
at Object.gotValue (/path/to/restbase/node_modules/bluebird/js/release/reduce.js:166:18)"},"stack":"TypeError: options.log is not a function\n
at Client.client.on (/path/to/restbase/node_modules/restbase-mod-table-cassandra/lib/index.js:107:17)\n
at Client.emit (events.js:198:13)\n at Client.log (/path/to/restbase/node_modules/cassandra-driver/lib/utils.js:99:8)\n
at Client._connectCb (/path/to/restbase/node_modules/cassandra-driver/lib/client.js:406:8)\n
at handlerWrapper (/path/to/restbase/node_modules/cassandra-driver/lib/utils.js:416:13)\n
at tryCatcher (/path/to/restbase/node_modules/bluebird/js/release/util.js:16:23)\n
at Promise.fromNode.Promise.fromCallback (/path/to/restbase/node_modules/bluebird/js/release/promise.js:209:30)\n
at Client.promiseWrapper (/path/to/restbase/node_modules/cassandra-driver/lib/utils.js:415:10)\n
at Client.connect (/path/to/restbase/node_modules/cassandra-driver/lib/client.js:384:31)\n
at makeClient (/path/to/restbase/node_modules/restbase-mod-table-cassandra/lib/index.js:113:19)\n
at RBCassandra.setup (/path/to/restbase/node_modules/restbase-mod-table-cassandra/index.js:210:16)\n
at makeRBCassandra (/path/to/restbase/node_modules/restbase-mod-table-cassandra/index.js:226:15)\n
at Router._loadModule (/path/to/restbase/node_modules/hyperswitch/lib/router.js:272:26)\n
at P.each (/path/to/restbase/node_modules/hyperswitch/lib/router.js:298:25)\n
at tryCatcher (/path/to/restbase/node_modules/bluebird/js/release/util.js:16:23)\n
at Object.gotValue (/path/to/restbase/node_modules/bluebird/js/release/reduce.js:166:18)",
"levelPath":"fatal/startup",
"msg":"Message not supplied",
"time":"2020-10-22T22:49:53.937Z",
"v":0
}
After lots of pain....
InvalidRequest: Error from server: code=2200 [Invalid query] message="Static column is not yet supported."
Amazon Keyspaces doesn't support Static column, and therefore it is not compatible with RESTBase.
Hi have an public wiki and in my setup I will have to use a shared Cassandra database.
I understand all that everything that will be cached is HTML/wikitext which is public to begin with, so even if my Cassandra database is, lets say, no so secure then that shouldn't be a big concern.
Would you agree that that assumption is correct?
Thank you
I'm struggling to get RESTBase working. I have parsoid set up and working fine on port 8000.
With RestBase I'm continuously getting the error:
{"type":"https://mediawiki.org/wiki/HyperSwitch/errors/not_found#route","title":"Not found.","method":"get","uri":"/my-site.wiki/v1/page/html/Main_Page"}
My mediawiki api is viewable at the path I set. Parsoid is accessible at 8000.
I tried changing all the instances of localhost to www.my-site.wiki. I've tried dropping the https and going with http, dropping the www. I'm at a bit of a loss for what I should try next. Some help would be greatly appreciated.
The docs say a route error suggests that the requested endpoint does not exist, but the page exists and the api path is correct.
Any idea on what I'm doing wrong? Or next steps for troubleshooting?
# RESTBase config for small wiki installs # # - sqlite backend # - parsoid at http:localhost:8000 # - wiki at https://www.my-site.wiki/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 - path: lib/normalize_headers_filter.js x-sub-request-filters: - type: default name: http options: allow: - pattern: https://www.my-site.wiki/api.php forward_headers: true - pattern: http://localhost:8000 forward_headers: true - pattern: /^https?:\/\// paths: /{domain:www.my-site.wiki}/{api:v1}: x-modules: - spec: info: version: 1.0.0 title: Wikimedia REST API description: Welcome to your RESTBase API. x-route-filters: - path: ./lib/normalize_title_filter.js options: redirect_cache_control: 's-maxage=0, max-age=86400' paths: /page: x-modules: - path: v1/content.yaml options: response_cache_control: 's-maxage=0, max-age=86400' - path: v1/common_schemas.yaml # Doesn't really matter where to mount it. /transform: x-modules: - path: v1/transform.yaml /{domain:localhost}/{api:sys}: x-modules: - path: projects/proxy.yaml options: backend_host_template: '{{"/{domain}/sys/legacy"}}' - spec: paths: /table: x-modules: - path: sys/table.js options: conf: backend: sqlite dbname: db.sqlite3 pool_idle_timeout: 20000 retry_delay: 250 retry_limit: 10 show_sql: false storage_groups: - name: local domains: /./ /legacy/key_value: x-modules: - path: sys/key_value.js /legacy/page_revisions: x-modules: - path: sys/page_revisions.js /post_data: x-modules: - path: sys/post_data.js /action: x-modules: - path: sys/action.js options: # XXX Check API URL! apiUriTemplate: https://www.my-site.wiki/api.php # XXX Check the base RESTBase URI baseUriTemplate: "{{'http://127.0.0.1:7231/{domain}/v1'}}" /page_save: x-modules: - path: sys/page_save.js /parsoid: x-modules: - path: sys/parsoid.js options: parsoidHost: http://localhost:8000 response_cache_control: 's-maxage=0, max-age=86400' # Finally, a standard service-runner config. info: name: restbase logging: name: restbase level: info
The log you posted reads: "uri":"/my-site.wiki/v1/page/html/Main_Page"
But in your config, the path reads: /{domain:www.my-site.wiki}/{api:v1}:
my-site.wiki is not the same as www.my-site.wiki, thus it doesn't match. You should change your config to match your actual domain.
My domain is at www.my-site.wiki, any attempt to use it without www redirects to www.my-site.wiki. I was testing any URL pattern that I could get to work and forgot to update it to the correct one in my initial post (when I test the URL with or without the www the result is the same error, that error is output at the testing URL).
When I change the url I'm using to test it to have the www I get the same error:
When I change the config to remove the www I get the same error:
{"type":"https://mediawiki.org/wiki/HyperSwitch/errors/not_found#route","title":"Not found.","method":"get","uri":"/www.my-site.wiki/v1/page/html/Main_Page"}
It is really unclear which sections of the page the bullet points are applicable to because the initial instruction appears at the top, then a bullet below the example. People read the top of the example, the do the changes, then read the bullet below (like this is not applicable unless...) and then they changed something they shouldn't have changed (because they were doing it in order and expect to be able to do it in order) and then it isn't exactly clear which section the bullet applies to... please but the bullets above the relevant example and below the instruction text. Then the bullets can have a colon at the end of each bullet statement to make it actually clear what they apply to.
Right now it is hard to decipher this page correctly so I'm doing it for someone else who found it to be hard to follow.
We don't skip the example, read below it, then look up to do the example... we read what's above the example (which is usually the instruction with any notes or bullet points below that), then look down at, then do the example.
Instead of:
Edit the config.yaml file in these parts:
(example)
- You don't need to change anything nor worry about this section unless you run a private wiki (see question)
It would be a lot better if it said:
If you run a private wiki, edit the config.yaml file in these parts:
(private wiki example)
Also edit the following in the config.yaml (public or private wikis) to fill in these parts:
- Relevant bullet above the example:
(example)
- Relevant bullet above the example:
(example)