English
Errors and warnings
Code: libs/yaml/src/lib.rs (Error), libs/codec/src/error.rs, libs/json/src/lib.rs (Span::line_column), crates/native-config/src/entity.rs (located), crates/config/src/lib.rs (error), crates/api/src/config.rs (Located).
Loading stops at the first error. Every error points to a place in the text:
FATAL bad.yaml: 4:7: unknown field `sever`, did you mean `server`? expected one of: server, uuid, flow, …
FATAL dup.yaml: 5:3: `d` is already the name of an outbound (first at 2:3)Three forms of an error
| Type | Who creates it | Position |
|---|---|---|
ours_yaml::Error { span, first, message } (= ours_native_config::Error) | YAML parsing, the loader | a span; first — the first occurrence of a repeated one |
ours_codec::Error { path, offset, message } | the codec, modules (ours_config::error, node helpers, Scope) | a byte offset |
ours_api::config::Located { message, span, first } | Provide::Check checks | spans from View::written |
Modules work with ours_codec::Error: a section or block decoder does not know the loader's error type. The loader translates it with located(error, fallback):
offset→ a zero spanoffset..offset; no offset —fallback, the place of the key under which the decoder was called (the key of the section, block, variant, protocol);- the codec's
path: dropped when there is an offset (the line and column give the place); without an offset the error is put on the block's key, andpathgoes as a prefix of the message — this shows which field inside the block is wrong.
The reverse translation is config_error in rules.rs: an error from Names called by a module through Scope is returned to the module as an ours_codec::Error.
Errors from building a component (Instance::check, Instance::new) arise after the loader has finished, so they carry no span. ours_native_config::place finds what it is about: outbound `x` /inbound `x` /endpoint `x` — an entity by Origin, parse rule[i]/dns rule[i] — a rule (the runtime index is dropped from the text), names inbound `x` — the first inbound: x in the file, log.level/ log.output — a field. check and run print file: line:column: message; an outbound from groups is called a group.
A Located from a check becomes Error::at_span(span) (or one without a position) with first_at.
YAML syntax
The parser reports where it gave up (often on the next line), and in its own words. ours_yaml restates it according to what is open at that place: an unclosed quote or bracket — unclosed quote `"` , unclosed `{`: no `}` closes it with the position of the opening character; an empty flow element — expected a value. An empty document (an empty file, only a comment, ~) the loader calls the configuration is empty, rather than naming the first missing field.
Line and column
Error::located(source) formats line:column: message and (first at line:column). Span::line_column counts by the bytes of the source, so the caller passes the same text it parsed (read_config_at, reload_subscriptions, Admin API). Span positions are in bytes; the YAML parser counts characters, and ours_yaml converts one into the other (YAML).
The spans of synthetic nodes point to what the node was made from: an error in a subscription server points to the subscription (with_span), in a rule from final — to final, in a dns.listen inbound — to the address.
Texts
Where possible, the texts say how to fix things:
`x` is a group: use `group: x`,`listen_port` belongs in `listen: host:port`,`tls` belongs inside the `vless` block,`multiplex` belongs in the `mux` block,the kind is the key, no `type`;finish/Map::finishand the codec —unknown field `x`, did you mean `y`? expected one of: ...(ours_codec::suggest: the closest name by edit distance, a list of up to 20 names). The codec's error is on the key. The codec knows field names in the runtime form (server_name,routing_mark), soload_withrestates its "unknown field" with the names the schema (ours schema) allows at that place in the file; where the schema does not describe the place — without a list. An unknown outbound or group name — also with the closest one (Names);- something not built into the binary —
... is not built in (feature `m`), something unknown —unknown ...; available: ...(sections); - the codec —
expected <type>, found <kind>,<n> does not fit <type>(a number outside the type's range).
Build errors (crates/kernel/src/instance.rs, without a position) name the entity: outbound `x`: …, inbound `x`: …, rule-set `x`: …, DNS server `x`: …. References the loader does not check are checked by the kernel's graph: a name in an inbound condition or in an inbound's detour — route names inbound `x`, which is not in the configuration, inbound[st] names inbound `x`, …; an outbound's detour — outbound `a` names `typo`, which is no outbound or group (from YAML such a reference is rejected earlier by the loader, with a position) (graph).
Warnings
Scope::warn/Context::warn accumulate strings in Loaded::warnings; loading is not interrupted. A warning is issued when the configuration will load, but perhaps not as intended, and this is a consequence of subscriptions being changeable:
- a subscription pattern or name currently selects nothing; a group is empty;
rank.manual.defaultis not a member right now;- a subscription group has vanished — it goes to
finalor refuses; - a subscription server did not load and was thrown out (the subscriptions module);
- the same for the DNS rule
outbound:(dns.rules: ...).
Consumers: check prints WARN ... to stderr, run and reload write to the log, and the subscriptions' own warnings (runtime::warnings) are added to them.
Build errors, not configuration errors
Modules::new errors (a repeated key, a point without an opener, a requires cycle) are errors of the binary: they are checked by tests and by the const check in app/ours/src/modules.rs, not by the user.