BadRequestError: child \"name\" fails because [\"name\" is required]

847 views
Skip to first unread message

Gareth Cox

unread,
Jun 25, 2015, 6:47:21 AM6/25/15
to aran...@googlegroups.com
Hi ArangoNites

I just got myself the latest 2.6.0 of Arango for Mac OS X using brew to install.

After following the todo Foxx example and getting that working, I decided to do almost the exact same thing on my own DB.
I created a DB, selected it, created an Application as per the example just different naming.
In the model I defined a schema as follows:

'use strict';
var Foxx = require('org/arangodb/foxx');
var joi = require('joi');

module.exports = Foxx.Model.extend({
  schema
: {
   
// Describe the attributes with joi here
    _key
: joi.string().optional(),
    name
: joi.string().required(),
    description
: joi.string().default("Node Type Description").optional(),
    deleted
: joi.boolean().default(false).optional()
 
}
});

I then go to the application and enter into the body the following:

{
 
"name": "Domain",
 
"description": "Domains",
 
"deleted": false
}

I click try and get the following error:

{
 
"error": true,
 
"code": 400,
 
"errorNum": 400,
 
"errorMessage": "child \"name\" fails because [\"name\" is required]"
}

Full Stack:

{
 
"exception": "BadRequestError: child \"name\" fails because [\"name\" is required]",
 
"stacktrace": [
   
"BadRequestError: child \"name\" fails because [\"name\" is required]",
   
"  at validateOrThrow (/usr/local/Cellar/arangodb/2.6.0/share/arangodb/js/server/modules/org/arangodb/foxx/request_context.js:104:11)",
   
"  at Object.instantiate [as construct] (/usr/local/Cellar/arangodb/2.6.0/share/arangodb/js/server/modules/org/arangodb/foxx/request_context.js:72:13)",
   
"  at /usr/local/Cellar/arangodb/2.6.0/share/arangodb/js/server/modules/org/arangodb/foxx/routing.js:318:45",
   
"  at execute (/usr/local/Cellar/arangodb/2.6.0/share/arangodb/js/server/modules/org/arangodb/actions.js:1308:7)",
   
"  at next (/usr/local/Cellar/arangodb/2.6.0/share/arangodb/js/server/modules/org/arangodb/actions.js:1325:7)",
   
"  at BaseMiddleware.middleware (/usr/local/Cellar/arangodb/2.6.0/share/arangodb/js/server/modules/org/arangodb/foxx/base_middleware.js:424:5)",
   
"  at execute (/usr/local/Cellar/arangodb/2.6.0/share/arangodb/js/server/modules/org/arangodb/actions.js:1308:7)",
   
"  at routeRequest (/usr/local/Cellar/arangodb/2.6.0/share/arangodb/js/server/modules/org/arangodb/actions.js:1329:3)",
   
"  at foxxRouting (/usr/local/Cellar/arangodb/2.6.0/share/arangodb/js/server/modules/org/arangodb/actions.js:1081:7)",
   
"  at execute (/usr/local/Cellar/arangodb/2.6.0/share/arangodb/js/server/modules/org/arangodb/actions.js:1308:7)",
   
"  at Object.routeRequest (/usr/local/Cellar/arangodb/2.6.0/share/arangodb/js/server/modules/org/arangodb/actions.js:1329:3)",
   
"  at Function.actions.defineHttp.callback (/usr/local/Cellar/arangodb/2.6.0/share/arangodb/js/actions/api-system.js:58:15)"
 
]
,
 
"error": true,
 
"code": 400,
 
"errorNum": 400,
 
"errorMessage": "child \"name\" fails because [\"name\" is required]"
}

Am I missing something?

Thanks
Dusty


Jan

unread,
Jun 25, 2015, 3:08:42 PM6/25/15
to aran...@googlegroups.com
Hi,

I just retried it with latest 2.6 on my local laptop (not MacOS). I created a new database via the web interface, switched into it, and then used the *Applications* tab to create an empty Foxx app.
In the app setup form, I put "/test" into the "Mount" text field and "test" into all others. After the app was created, I set it to development mode, using the "Set dev" button.
I then edited the generated model file to reflect the schema changes you made.
After that, I used the POST /test route of the app via the web interface. I copied this JSON into the big "parameters" textbox and submitted:

{
"name": "Domain",
"description": "Domains",
"deleted": false
}

I got a server response of HTTP 200 then, with the following body:


{ "name": "Domain", "description": "Domains"
,
  "deleted": false,
  "_key": "1116341081"
}

So it's working for me... I also retried with curl and got an HTTP 200 from it, too:

curl -X POST http://127.0.0.1:8529/_db/mydb/test/test --data '{"name": "Domain","description": "Domains","deleted": false}'
 {"name":"Domain","description":"Domains","deleted":false,"_key":"1128268633"}

As it doesn't work for you, I suggest checking the following:
- can you try it with a minimal app setup as I described it above? Maybe you already did, this wasn't 100% clear to me. If yes, there's no need to repeat it.
- is your application set to development mode so all changes made to the files (model etc.) are actually in effect?
- if still not working, could you create zip/tarball of the app directory so we can try reproducing with the actual app code?

Thanks!

Maybe someone else has another idea... I read something about bugs being fixed recently in the 2.6.0 web interface. Maybe it has to do with that, but that's purely a guess.

Best regards
J

Gareth Cox

unread,
Jun 26, 2015, 2:53:12 AM6/26/15
to aran...@googlegroups.com
Hi

Thanks for the reply

After more testing I've gotten really strange results.
I created a simple testapp and it worked, as you described.
I then recreated my app EXACTLY like the test app, but with a different collection name, and it fails.
I then recreated my app with a collection called testCollection (as in my test app) and my own collection.
Here is the weird part, it works on testCollection but now my own nodeTypes.
the model code is copy/pasted from testCollection to nodeTypes, so its identicle.
I've attached the zip.

Thanks
Dusty
app.zip

Wilfried Goesgens

unread,
Jun 26, 2015, 4:48:27 AM6/26/15
to aran...@googlegroups.com
Hi Gareth,
I've been able to reproduce it with your foxx app.
The problem itself is, that the swagger js UI sends an empty post body, though I've pasted your document into the edit window.
I've created https://github.com/arangodb/arangodb/issues/1387 to better track this.

Cheers,
Willi
--
You received this message because you are subscribed to the Google Groups "ArangoDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to arangodb+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Alan Plum

unread,
Jun 28, 2015, 7:20:31 PM6/28/15
to aran...@googlegroups.com
Hi Gareth,

thanks for bringing this issue to our attention. I will look into it when I'm on site this Tuesday.

The API documentation has been upgraded to Swagger 2.0 in ArangoDB 2.6 so this may be a bug in the code that generates the JSON schema for Swagger or a quirk in how Swagger 2.0 parses schemas.

Cheers,

Alan
Reply all
Reply to author
Forward
0 new messages