Skip to main content

Psi: errors and limits

A load reports every error it can find without guessing, each with where it is, what was found and, often, what to do about it:

server {
host = localhost
port: 8080 timeout: 5s
}
name: my service
url: "jdbc:{$db.host}"

reports

3 errors in 1 source
app.psi
2:8: expected ':', ':=' or '{' after a key, found '='
hint: write a field as 'key: value' or 'key { … }'
3:14: expected ',' or a line break, found 'timeout:'
hint: separate items with ',' or a line break; whitespace never separates
5:10: a second word, 'service', after a value
hint: quote a value with whitespace in it, as in "foo bar"

Errors in the syntax come first. Substitutions are resolved only when there are none, so that a field the syntax lost is not reported as missing: {$db.host} above is reported once the rest is fixed.

Limits​

A tree loaded is at most 128 levels deep, counting each {, [ and key after a dot; a source a directive such as #include reads starts a level below the call, among fields too. Resolving a substitution goes at most 128 steps, each a level descended or a substitution followed, a substitution used again counting as deep as it went the first time. So a chain of substitutions goes 128 links, whatever order its keys are written in. Resolving substitutions adds at most 1 000 000 nodes, those grafts copy and those a directive such as #yaml brings, every use of a YAML alias counted, and 10 000 000 characters, those of the scalars concatenations build; a source's own size is not limited. Reading the sources of a load takes at most 10 000 000 bytes, every read counted, and 60 seconds; a wait already begun runs its course, but a read that ends past the time fails all the same. Past any of these limits, the load reports an error. A program can set another limit.