feat: template fallback operator ${expr || 'default'}#2551
feat: template fallback operator ${expr || 'default'}#2551hardyjosh wants to merge 2 commits intolist-tokensfrom
Conversation
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
042f0ae to
c36d2a8
Compare
38992d1 to
129f279
Compare
ac7b4e7 to
6797f34
Compare
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
6797f34 to
5937168
Compare
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
When a template path resolves to a missing token field (select-token
not yet selected) and a fallback literal is supplied, substitute the
literal instead of leaving the placeholder raw or erroring.
Syntax:
${path} — current behaviour
${path || 'fallback'} — new: substitute literal on missing token
${path || "fallback"} — double quotes also accepted
Backwards-compatible: existing templates without `||` behave identically.
The fallback only kicks in on PropertyNotFound("token") (i.e. unresolved
select-token), not on other resolution errors.
This unblocks --describe emitting readable field names/descriptions when
no token has been selected yet.
5937168 to
988ae03
Compare

Caution
Stacks on #2549. Merge that first.
Motivation
Strategy field names and descriptions in
.rainYAML reference token properties via templates like\${order.inputs.0.token.symbol} per \${order.outputs.0.token.symbol}. The webapp resolves these at runtime once tokens have been selected. Any other consumer (notably--describe) that renders these strings before a token is picked sees the raw placeholder, which is confusing.Dropping the placeholder in un-selected contexts would lose the structural information. Hard-coding a substitution in every consumer is brittle and doesn't match webapp semantics.
Solution
Extend the template syntax with an optional fallback literal:
The fallback only kicks in on
PropertyNotFound("token")(i.e. select-token not yet selected). Other resolution errors still propagate. Templates without||behave identically to today — backwards compatible.The webapp gets no regression: when tokens are selected the left-hand side always resolves and the fallback never fires.
--describe(and any other "no context" consumer) gets readable output for free once registry strategies adopt fallbacks.Registry adoption is tracked in ST0x-Technology/st0x.registry#9.
Checks