So if I do the above in the "real" code the following error is thrown:
ValidationError: Invalid state definition defaults {
"strictHeader": true,
"ignoreErrors": false,
"isSecure": false,
"isHttpOnly": false,
"path": null,
"domain": null,
"ttl": null,
"encoding": "none",
"failAction" [1]: "log", ***
"parse" [2]: false ***
}
[1] "parse" is not allowed
[2] "failAction" is not allowed
at Object.exports.Err.exports.process
(/Users/rpotter/Documents/SourceControl/cnn-google-amp-service/node_modules/joi/lib/errors.js:154:19)
Now if this is the case you could assume that some object nesting is needed based on the above.
From the schema.js file it is eventually deduced(fact check please) that state is located in the object like this:
server
host
port
tls
connections
routes
state
parse
failAction
However constructing the connectionOptions object to handle this nesting state results in an error as well. There's a double dose of state parse failAction because the routes object from the AMP app contains the state information into it. Right now my main.js(custom tweaked) is set to also build the second state config you see below.
Looking at the HAPI schema JOI is enforcing it looks like having state under "routes" is the way to go.
Here's that error mentioned:
"connections" [1]: {
"routes": {
"files": {
"relativeTo": "/Users/rpotter/Documents/SourceControl/cnn-google-amp-service/public"
},
"state": {
"parse": false,
"failAction": "log"
}
},
"state": {
"parse": false,
"failAction": "log"
}
}
[1] "connections" is not allowed
at Object.exports.unique.exports.contain.exports.reachTemplate.exports.assert.condition [as assert] (/Users/rpotter/Documents/SourceControl/cnn-google-amp-service/node_modules/hoek/lib/index.js:736:11)
at Object.exports.apply (/Users/rpotter/Documents/SourceControl/cnn-google-amp-service/node_modules/hapi/lib/schema.js:17:10)
Vague references from schema.js on how state is nested under routes below:
schema.js line: 60
JIRA Ticket http://tickets.turner.com/browse/CNNGAMP-193
Error To reproduce the error run the cnn amp app and load the following example url.
Once loaded create a custom cookie with the name value pair as follows and then refresh the page:
After refreshing the page you should get this error:
Why this relates to/depends on CNN-HAPI HAPI parses cookies and stores them into the request state. Here are similar logged issues. https://github.com/hapijs/hapi/issues/2513 https://github.com/hapijs/statehood/issues/11
Discovered thus far: Pseudo code representation of main.js from cnn-hapi module
Assume the below options.connections.routes.state. is there - just to shorten this example
From schema.js in cnn-hapi module - JOI(module) schema enforcement object notice there is nothing for routes or state allowed
So if I do the above in the "real" code the following error is thrown:
Now if this is the case you could assume that some object nesting is needed based on the above.
From the schema.js file it is eventually deduced(fact check please) that state is located in the object like this:
However constructing the connectionOptions object to handle this nesting state results in an error as well. There's a double dose of state parse failAction because the routes object from the AMP app contains the state information into it. Right now my main.js(custom tweaked) is set to also build the second state config you see below.
Looking at the HAPI schema JOI is enforcing it looks like having state under "routes" is the way to go.
Here's that error mentioned:
Vague references from schema.js on how state is nested under routes below: schema.js line: 60
Schema.js line: 173 Where routeBase is used?
Where connectionBase is used? schema.js line 187