Skip to main content

Module warnings

Module warnings 

Source
Expand description

Load-time scan for unresolved {{...}} template syntax.

collect_template_warnings walks every string leaf of every node config across policies, supernodes, and plugin_configs, collecting one coordinated warning per unresolved reference via Template::source_warnings_only. It is pure logging support: it never fails the config, it only surfaces likely typos (e.g. {{request.headres.x}}) at load time instead of leaving them to render as silent literals on every request.

Call this on the gateway config after resolve_plugin_configs has run (SharedState::compile_routes does so right after resolution; the debug sandbox does the same on its synthesized/stored single-policy gateway before compiling). Walking the resolved copy means a config_ref’d node’s merged-in shared config is covered too, reached through the policy/supernode walk. plugin_configs are also walked directly (as their own container) so a shared config with no current referrer still gets flagged.

Warnings are advisory only, not proof of a bug: the walker inspects every string leaf generically and has no notion of per-plugin field semantics. A handful of fields intentionally use their string value verbatim, never templated — e.g. limit-conn’s key in key_type: constant mode — so a constant value that happens to contain {{...}} draws a spurious warning here. Accepted false positive; do not try to special-case field names in this generic walker.

Functions§

collect_template_warnings
Walks every string leaf of every node config in gw (policies, supernodes, plugin_configs) and returns one fully-coordinated warning per unresolved {{...}} reference found. See the module doc for placement and caveats.
leaves 🔒
Recursively collects (path, warning) pairs from every string leaf of value. path starts at root (the top-level config key) and accumulates dotted object keys (headers.x-custom) and [i] array indices (list[1]) down to the leaf that produced the warning.
walk 🔒