You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a generated Hydra API description that contains a variable with an invalid variable-name 0he.
On startup, hydra routes get created sucessfully, no errors. Some parts of the API can be called successfully, while others fail with HTTP 500. Interesting is, that besides the part where the invalid variable-name is used, also not directly related parts are failing.
I propose to:
investigate why not directly related parts are failing
consider validating the API description on startup, in order to fail fast
Without any modifications to the source, the Shape-API only contains one Dataset (BEW-RAUM-ZEIT-HEL). The API description is in the folder api_apidev.
Let's hit the API with curl:
$ curl -s -i -H "accept:application/ld+json" http://localhost:8080/dataset/BEW-RAUM-ZEIT-HEL | head -1
HTTP/1.1 200 OK
In order to be able to update the API afterwards, setting the password for the SPARQL Endpoint as environment variable is necessary. Endpoint and user are defined in api-config.apidev.js.
$ export SPARQL_ENDPOINT_PASSWORD=foopass!_987
Now we will add Dataset BES-RAUM-ZEIT-0-0HE-BE to the API. Activate BES-RAUM-ZEIT-0-0HE-BE in the WHITELISTINGviewFilter, in the configuration-file api-config.apidev.js and update the API with the following command. The Shape-API will be generated for all Datasets matching the viewFilter.
$ npm run update-api-apidev
$ ls -w1 api_apidev
api.jsonld
BES-RAUM-ZEIT-0-0HE-BE-shape.sparql.es6
BES-RAUM-ZEIT-0-0HE-BE-slice.sparql.es6
BEW-RAUM-ZEIT-HEL-shape.sparql.es6
BEW-RAUM-ZEIT-HEL-slice.sparql.es6
shape.context.jsonld
slice.context.jsonld
No errors on startup. Hit the API again with curl:
$ curl -s -i -H "accept:application/ld+json" http://localhost:8080/dataset/BEW-RAUM-ZEIT-HEL | head -1
HTTP/1.1 500 Internal Server Error
Stacktrace:
SyntaxError: Invalid or unexpected token
at Function (<anonymous>)
at Function.evalTemplateString (/home/mira/git/stat.stadt-zuerich.ch/node_modules/hydra-box/lib/SparqlView.js:90:22)
at SparqlView._handle (/home/mira/git/stat.stadt-zuerich.ch/node_modules/hydra-box/lib/SparqlView.js:41:30)
at Layer.handle [as handle_request] (/home/mira/git/stat.stadt-zuerich.ch/node_modules/express/lib/router/layer.js:95:5)
at next (/home/mira/git/stat.stadt-zuerich.ch/node_modules/express/lib/router/route.js:137:13)
at Route.dispatch (/home/mira/git/stat.stadt-zuerich.ch/node_modules/express/lib/router/route.js:112:3)
at Layer.handle [as handle_request] (/home/mira/git/stat.stadt-zuerich.ch/node_modules/express/lib/router/layer.js:95:5)
at /home/mira/git/stat.stadt-zuerich.ch/node_modules/express/lib/router/index.js:281:22
at Function.process_params (/home/mira/git/stat.stadt-zuerich.ch/node_modules/express/lib/router/index.js:335:12)
at next (/home/mira/git/stat.stadt-zuerich.ch/node_modules/express/lib/router/index.js:275:10)
at next (/home/mira/git/stat.stadt-zuerich.ch/node_modules/express/lib/router/route.js:127:14)
at tryCatcher (/home/mira/git/stat.stadt-zuerich.ch/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/home/mira/git/stat.stadt-zuerich.ch/node_modules/bluebird/js/release/promise.js:512:31)
at Promise._settlePromise (/home/mira/git/stat.stadt-zuerich.ch/node_modules/bluebird/js/release/promise.js:569:18)
at Promise._settlePromise0 (/home/mira/git/stat.stadt-zuerich.ch/node_modules/bluebird/js/release/promise.js:614:10)
at Promise._settlePromises (/home/mira/git/stat.stadt-zuerich.ch/node_modules/bluebird/js/release/promise.js:693:18)
Other parts of the API still work:
$ curl -s -i -H "accept:application/ld+json" http://localhost:8080/dataset/ | head -1
HTTP/1.1 200 OK
The culprit seems to be in api_apidev/api.jsonld. If I remove the following snippet, the aforementioned API call doesn't fail anymore:
I have a generated Hydra API description that contains a variable with an invalid variable-name
0he
.On startup, hydra routes get created sucessfully, no errors. Some parts of the API can be called successfully, while others fail with
HTTP 500
. Interesting is, that besides the part where the invalid variable-name is used, also not directly related parts are failing.I propose to:
Following are the steps to reproduce:
Software under test: https://github.com/statistikstadtzuerich/stat.stadt-zuerich.ch
Start the API Backend:
Without any modifications to the source, the Shape-API only contains one Dataset (BEW-RAUM-ZEIT-HEL). The API description is in the folder api_apidev.
Let's hit the API with curl:
In order to be able to update the API afterwards, setting the password for the SPARQL Endpoint as environment variable is necessary. Endpoint and user are defined in api-config.apidev.js.
Now we will add Dataset BES-RAUM-ZEIT-0-0HE-BE to the API. Activate
BES-RAUM-ZEIT-0-0HE-BE
in the WHITELISTINGviewFilter
, in the configuration-file api-config.apidev.js and update the API with the following command. The Shape-API will be generated for all Datasets matching the viewFilter.Restart the backend:
No errors on startup. Hit the API again with curl:
Stacktrace:
Other parts of the API still work:
The culprit seems to be in api_apidev/api.jsonld. If I remove the following snippet, the aforementioned API call doesn't fail anymore:
Notice, that we call the API for BEW-RAUM-ZEIT-HEL, whereas the problem comes in with BES-RAUM-ZEIT-0-0HE-BE, a different dataset.
I guess that with the respective API calls, also the following two occurrences of the variable
0he
would cause failure. I didn't try it out though:in api.jsonld:
in BES-RAUM-ZEIT-0-0HE-BE-slice.sparql.es6:
The text was updated successfully, but these errors were encountered: