1

Using ArangoDB documentation version 3.3 or version 3.4 for the Getting Started section of Foxx Microservices, I can't get past this error:

Failed to load API definition.

NetworkError when attempting to fetch resource. http://192.168.1.1:8529/_db/_system/_admin/aardvark/foxxes/docs/swagger.json?mount=/getting-started

That error is shown on the API tab of the service. After installing my service according to the tutorial, I get the service's card as described. I click that card and then click the API tab and the above error is shown.

To eliminate typos, I have tried copying and pasting the exact file contents from the ArangoDB documentation and following every step exactly, and I still get the same error.

The Info tab of my newly created getting-started service contains this info:

Author:
Mount: /getting-started
Mode: Development
Version: Unknown
Version License: Unknown License
Path: /var/lib/arangodb3-apps/_db/_system/getting-started/APP

The example contains only two files and they are:

manifest.json

{
  "engines": {
    "arangodb": "^3.0.0"
  },
  "main": "index.js"
}

index.js

'use strict';
const createRouter = require('@arangodb/foxx/router');
const router = createRouter();

module.context.use(router);

router.get('/hello-world', function (req, res) {
res.send('Hello World!');
})
.response(['text/plain'], 'A generic greeting.')
.summary('Generic greeting')
.description('Prints a generic greeting.');

The canned demo services, such as the hello-fox example, work correctly. I collected more error information:

Navigating to http://192.168.1.1:8529/getting-started

404: errorMessage "unknown path '/getting-started'"

Navigating to http://192.168.1.1:8529/_db/_system/getting-started

404: errorMessage "unknown path '/getting-started'"

The console also shows:

WARNING File not found "/getting-started": file "" does not exist in "/var/lib/arangodb3-apps/_db/_system/getting-started/APP/files".

The tutorial doesn't indicate another file named getting-started or another location for the two specified files. What am I missing?

BugBuddy
  • 576
  • 2
  • 5
  • 19
  • 1
    Check the logs in the web gui after you see the error message (remember to refresh the page as it does not refresh on its own). Are there any error message there? – camba1 Dec 18 '18 at 21:53
  • @camba1 - thanks. My error is: File not found "/getting-started": file "" does not exist in "/var/lib/arangodb3-apps/_db/_system/getting-started/APP/files". – BugBuddy Dec 18 '18 at 23:42
  • 1
    Try adding "main" in your manifest file and pointing it to index.js. Assuming index.js is in the same directory as your manifest, try: { "engines": { "arangodb": "^3.0.0" }, "main": "index.js" } In terms of the endpoint address your service is hosted at, it should be something like: `http://localhost:8529/_db/_system/testService/hello-world` – camba1 Dec 19 '18 at 00:17
  • @camba1 - ArangoDB is running on a local computer and I can access the web ui at http://192.168.1.1:8529/ fine. Other services run. I added ` "main": "index.js" ` again. I had tried it before, and I still get the same error. Regarding the endpoint, I tried `http://192.168.1.1:8529/getting-started` and `http://192.168.1.1:8529/_db/_system/getting-started`. I'm not sure about the path element `testService` in your comment because nothing in the tutorial tells me to create a directory anywhere. The Arango web ui installs my zip file here `/var/lib/arangodb3-apps/_db/_system/getting-started/` – BugBuddy Dec 19 '18 at 00:27
  • Arango's tutorial says `You will need to provide a mount path, which is the URL prefix at which the service will be mounted (e.g. /getting-started)`. So I used `/getting-started`. However, I now notice that the router has a path defined as `/hello-world`. Changing that to /getting-started` did not resolve my error, but removing the path completely did fix it. Clearly, I do not understand something about the paths and endpoints required. I'm confused. – BugBuddy Dec 19 '18 at 00:45
  • 1
    Sorry about the confusion on the end point, it was just an example. For you it would be http://192.168.1.1:8529/_db/_system/getting-started/hello-world .Also I see the service on development mode. Thus service is reloaded every time you open it. and you can modify your files directly in /var/lib/arangodb3-apps/_db/_system/getting-started/ instead of having to load a new zip file every time you make a change (does not solve your issue but makes debugging easier). Also, the log shows the real error. The service gui shows just generic error as you probably figure out by now. – camba1 Dec 19 '18 at 00:53
  • Your last comment and some experimentation clears it up for me finally. Do you want to provide an answer for me to accept? – BugBuddy Dec 19 '18 at 02:30

1 Answers1

0

This issue was resolved based on the helpful comments by @camba1. There was no problem with Arango, just a problem with me understanding the tutorial. For others in my position, here are the things I did not understand properly and that, when addressed, resolved my problems.

  1. The API tab, in contrast to what the tutorial says, will give the error "Failed to load API definition" even for a correctly working service. Ignore that error message. I am not yet using the API tab at all.

  2. the tutorial refers to two paths, '/hello-world' and '/getting-started'. These are used on the endpoint (URI) and in creating the router like below:

    router.get('/hello-world', function (req, res) { ...

The tutorial wasn't as clear as it could have been on this point, but as @camba1 pointed out, the service endpoint would end up incorporating both of those elements:

192.168.1.1:8529/_db/_system/getting-started/hello-world .
  1. this very basic demo is easier and better in my opinion when the router is created without a path:

    router.get(function (req, res) {

In this case it defaults to a path of '/'. I think this may avoid confusion for raw beginners like me. The service endpoint then becomes one element simpler. In my case, the endpoint (with Arango running on another computer on the LAN) becomes:

192.168.1.1:8529/_db/_system/getting-started

The tutorial would be improved if it either added a couple extra sentences to explain how the endpoint is constructed, or alternatively, did as I suggested above and simplified things by one step.

BugBuddy
  • 576
  • 2
  • 5
  • 19
  • For anyone else reading this, I updated from ArangoDB 3.3.19 to 3.4 and these simple demos which were working are no longer working. Something about the path definition in router.get seems to have changed. – BugBuddy Dec 22 '18 at 03:39
  • May I ask you @BugBuddy how to install @arangodb/foxx ? I didn't find it: https://www.npmjs.com/search?q=%40arangodb – Raphael10 Dec 03 '21 at 12:41