Skip to content

feat(expr): JSON-pointer sub-access on $inputs and $steps references - #90

Merged
emmanuelperu merged 3 commits into
mainfrom
feat/spec-expr-pointers
Jul 8, 2026
Merged

feat(expr): JSON-pointer sub-access on $inputs and $steps references#90
emmanuelperu merged 3 commits into
mainfrom
feat/spec-expr-pointers

Conversation

@emmanuelperu

Copy link
Copy Markdown
Owner

Closes #49, the last open spec-compliance issue.

What

The spec's runtime-expression examples apply #/<json-pointer> sub-access to step outputs ($steps.someStepId.outputs.pets#/0/id) and inputs; those references used to ship verbatim into generated tests. They are now translated, with every strategy validated against the real tools before implementation:

  • expr: Parse accepts the pointer suffix on $inputs and $steps...outputs references (a bare # keeps whole-value semantics; #x stays unrecognised).
  • Hurl, step outputs: a sub-accessed output becomes a derived capture at the producing step, the pointer folded into the source capture's jsonpath (list_body_items_0_id: jsonpath "$.items[0].id"), with collision-safe naming. This is the only strategy that works: probing hurl 8.0.1 showed that member access on a structured capture is unrenderable at run time and that placeholder filters parse but are silently ignored (the raw variable is rendered), which would have produced silently wrong requests.
  • Hurl, inputs: explicitly flagged as untranslated, for the same verified reason: Hurl offers no render-time sub-access on a variable. Documented in the matrix.
  • k6, step outputs: captured constants are parsed JSON, so the pointer becomes a bracket chain (list_pets["0"]["id"]; string indices address arrays in JS).
  • k6, inputs: a per-reference asJson() helper parses string values on use, so an input referenced both whole and sub-accessed keeps its raw string for the whole-value use (no module-init parse, no mixed-use corruption).
  • Linter: $steps output names may contain inner dots per the spec's name pattern; a dotted-name miss whose first segment IS a declared output now hints at the #/<json-pointer> form.
  • The pre-scans mirror exactly what the writers serialise: post-replacement payloads, unresolved reusable parameters excluded, delegate steps skipped.

Verification

  • Four empirical hurl 8.0.1 probes (member access, filters on captures, derived captures, filters on variables) drove the design; the misleading probe (a 200 from a permissive server) was caught and re-tested with rendered-output inspection.
  • Scratch workflow chaining GET /products/{$steps.list.outputs.body#/items/0/id} executed against the local mock: 100% pass in Hurl; k6 script validated with k6 archive and navigates the parsed value.
  • Full suite (11 packages), vet, gofmt, golangci-lint clean (2 pre-existing gosec findings in scripts/hurl-demo only); make lint dist hurl perf on all examples with byte-identical examples/generated; e2e on the mock 100% pass.
  • 8-angle adversarial review; confirmed findings fixed: the silently-ignored-filter strategy scrapped (worst-failure-mode prevention), mixed whole/pointer input use, module-init JSON.parse crash, dead derived captures from dropped parameters, spec-claim accuracy in comments (ABNF vs spec examples), linter regex heuristic documented honestly.

expr.Parse accepts the #/<json-pointer> suffix the spec's examples apply to $inputs and $steps output references (e.g. $steps.someStepId.outputs.pets#/0/id), and the generators translate it with strategies verified against the real tools. In Hurl, a sub-accessed step output becomes a derived capture at the producing step, folding the pointer into the source jsonpath: placeholder member access on a structured capture is unrenderable and placeholder filters are silently ignored (both verified empirically against hurl 8.0.1), so render-time navigation is impossible and $inputs sub-access stays explicitly flagged there. In k6, step outputs are parsed JSON constants navigated with bracket chains (string indices work on arrays), and $inputs sub-access goes through a per-reference asJson helper so a whole-value use of the same input keeps its raw string.

The hurlgen internals move onto a translator struct carrying the derived-capture plan produced by a pre-scan of the workflow (post-replacement payloads, unresolved reusable parameters excluded, workflow-invoking steps skipped); derived names are collision-checked against declared captures. The linter's $steps regex now accepts inner dots in output names per the spec's name pattern (leading/trailing dots excluded to avoid swallowing prose punctuation), and a dotted-name miss whose first segment is a declared output gets a hint pointing at the #/<json-pointer> form.
The stdlib advisory GO-2026-5856 (Encrypted Client Hello privacy leak in crypto/tls, fixed in go1.25.12) fails govulncheck on every PR; CI reads the version from go.mod.
@emmanuelperu
emmanuelperu merged commit 5eaddc7 into main Jul 8, 2026
6 checks passed
@emmanuelperu
emmanuelperu deleted the feat/spec-expr-pointers branch July 8, 2026 21:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

expressions: JSON-pointer suffixes, whole-body references and the ABNF name charset

1 participant