--- id: LANG-9 family: GR-LANG level: core profiles: [runtime] posture: normative-target added: "1.0" changed: "1.0" source: https://flowdrop.io/spec/rules/gr-lang/lang-9 specification: FlowDrop Workflow Specification 1.0 licence: CC BY 4.0 --- # LANG-9 — A JSONPath miss falls back to the default; an error never does *GR-LANG (Part I) · level: core · profiles: runtime · added in 1.0* ## The rule > **Normative.** This is the rule. > > 1. JSONPath evaluation MUST distinguish a miss from an error. > > 2. A query that runs cleanly and matches nothing is a miss: it yields the default the caller supplied, `null` where none was supplied, and the evaluation MUST report that nothing matched. > > 3. A query that cannot be compiled or cannot be run is an error: it MUST be reported as one, and MUST NOT yield the default (LANG-22, LANG-29). > > 4. A query that matches a `null` MUST yield `null` and report a match, never the default. ## What it means A JSONPath query can come back empty-handed in two quite different ways: it runs cleanly and matches nothing, or it never runs at all because the string does not compile or the engine fails. Only the first is a miss. A miss hands back whatever default the caller supplied, `null` if none was given, and says that nothing matched. An error is reported as an error and never turns into the default, so a typo in a query cannot pass for data that simply is not there. What the caller can also always tell is whether the query matched: a query that matches a stored `null` returns that `null` and reports a match, never the default. ## Example Two queries against the same data, with the same supplied default: `$.store.nonexistent`, which compiles and runs but matches nothing, and `$.[invalid`, which cannot compile. ```json title="What the query that matches nothing returns" verdict="fallback" "fallback" ``` The query that cannot compile returns no value at all: it is reported as an error, and a node evaluating it fails (LANG-22). ## Why Recorded under [OPEN-25](https://flowdrop.io/spec/rulings/open-25), [OPEN-26](https://flowdrop.io/spec/rulings/open-26), [OPEN-40](https://flowdrop.io/spec/rulings/open-40). ## Fixtures Test cases whose outcome this rule decides (fixtures/README.md defines each operation): - A query that matches null delivers null and reports a match (`extract`): fixtures/presence/lang-match-null-delivered.json - A query that matches nothing delivers the default and reports a miss (`extract`): fixtures/presence/lang-miss-delivers-default.json ## Related rules - Names: LANG-8 - Referenced by: LANG-6 --- Rule identifiers are permanent and are never renumbered. This specification carries no implementation status: each implementation publishes its own standing against these rules. Licensed CC BY 4.0.