ytt icon indicating copy to clipboard operation
ytt copied to clipboard

"#@data.values" [no space after @] should error with a helpful hint

Open cppforlife opened this issue 4 years ago • 4 comments

Describe the problem/challenge you have users may accidentally forget to have a space in foo: #@data.values after @ and be confused why the data value is not showing up in the output.

(https://twitter.com/stylishandy/status/1455051198935957514?s=20)


Vote on this request

This is an invitation to the community to vote on issues, to help us prioritize our backlog. Use the "smiley face" up to the right of this comment to vote.

👍 "I would like to see this addressed as soon as possible" 👎 "There are other more important things to focus on right now"

We are also happy to receive and review Pull Requests if you want to help working on this issue.

cppforlife avatar Nov 02 '21 19:11 cppforlife

I'm tempted to generalize this issue as, "Whenever there's an unrecognized annotation, ytt should error; in some set of common situations include a hint."

"Common Situations" could include:

  • #@load(...
  • #@data.values...
  • (in general) #@{module-name}.... (e.g. #@json.)
  • (in general) #@{starlark-builtin}... (e.g. #@if, #@for, ...)

Where the hint could note the needed space:

ytt: Error: Overlaying data values (in following order: overlay.yml):
  Document on line overlay.yml:7:
    Map item (key 'foo') on line overlay.yml:9:
      Unknown annotation '@data.values.replicas' (did you mean '@ data...`, with a space after the '@'?)

Thoughts?

pivotaljohn avatar Nov 03 '21 21:11 pivotaljohn

i like where you going with it. this does make me think about backwards and forwards compatibility. do we get a benefit for being able to use unknown annotations today? (e.g. if some data values passed in i can use newer ytt functionality otherwise fall back? if we check annotations early enough this would become problematic...)

there is something to be said about possibility of doing short-term hinting and then potentially filling in more comprehensive changes.

cppforlife avatar Nov 04 '21 13:11 cppforlife

this does make me think about backwards and forwards compatibility.

Ditto. I'm thinking of putting a feature flag on it (as in the user-facing feature flag). It would be more ytt-ish if we'd be stricter by default and be able to relax with the flag.

Something like... idonno... --ignore-unknown-annotations 😁 .

pivotaljohn avatar Nov 04 '21 20:11 pivotaljohn

This idea is an aspect of #114

pivotaljohn avatar Nov 05 '21 23:11 pivotaljohn