-
Notifications
You must be signed in to change notification settings - Fork 147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Identifying strings are expressions in place where the string might also be a constant #848
Comments
Relevant prior discussion: #285 (#285 (comment) even includes several of these options) |
@fjtirado as discussed in PM, I totally understand your point of view, which is documented insightfully by others in the issue shared by @gibson042 (thank you!). As I have never been bothered by the current approach, which I actually like, I'm probably not the most objective person when it comes to that subject. I did, however, my due diligence, and have checked what major clouds are proposing, and it seems they are all using a similar mechanism. Hell, Google Workflows, which is my personnal favorite, uses the exact same than us. Google Workflows, however, recommends single quoting expressions in YAML (which is/should be the authoring language) to avoid many of the problems you guys mentionned. My proposal is:
document:
dsl: '1.0.0-alpha1'
namespace: example
name: example-workflow
version: '0.1.0'
evaluate:
language: jq
expressions: explicitly | implicitly Where Also, I'm not against replacing the actual '${ }' with something else, as suggested in 2. Finally, while I believe 1 is a great way to go, too, I think it is best "enabled" using my proposal, rather than by default. The reason is that, in the end, this issue is really a matter of tastes, perceptions and habits. Enforcing one or the other (such as it has been done so far) is IMO not the way to go. What I would avoid is:
It's more complicated, less readable, less "user-friendly", and a IMO a PITA to implement (where before I could simply regex my way out of it, I must know define special constructs to "extend" normal properties). My opinion is that option costs much more than it gives. As for suggestions to replace the current approach with an |
@cdavernas |
Well, why would you go through the sheer pain of defining anything in JSON when you can do it in YAML, I wonder? |
@cdavernas |
I believe you, and that's your right. But I am convinced that it will probably not be the case of the majority of our (especially non-technical) audience, which I'd rather focus on (as per design).
Well, first, it's a matter of taste and colors, really. Second, I was looking to what was done where and why. The reasons identified and addressed by our "competitors" is of high interest to me, especially Google Workflows, which I admitted to be really fond of, on a purely syntaxic perspective. The fact is that while having to build a JSON string should be doable, it's rather something you'd like to avoid, as you'd loose control over the data, which becomes opaque to any component of you workflow. Please rest assured I read through and through the discussion we had on slack, the issue #285 and the new example supplied above. My opinion/taste remains the same nonetheless. I therefore propose we all avoid trying to convince each other, and rather provide constructive solutions that could address the issue at hand! I still believe we are speaking of edge cases twhich can be addressed in a way that becomes painfull for standard cases. Let's remain concise in this issue, and move discussions to... discussions. I propose we only make and discuss proposals in here! On a final note, it might be interesting to document those kind of fundamentals issues in ADRs, what do you @ricardozanini |
Given your personal preferences, my proposal is to change |
In #285 I think we were both discussing (makes sense at that moment) expression interpolation (which we are not supporting anymore, since we are deferring to the expression language) with expression identification (and the fact that were forcing the usage of |
and now my two cents, The markup proposal (either ${} or ##), since it can be used for interpolation, does not clearly send the message that we are NOT supporting it. |
I realize
when currently you have to write
or
|
|
@ricardozanini what we are doing is writing an string that contains an expression that is evaluated. |
@fjtirado I'm just adding to the discussion, I already agreed with |
Also, we should be more strict defining what the expression should be returning. |
…untime expression language and mode. Partially addresses serverlessworkflow#848 Signed-off-by: Charles d'Avernas <charles.davernas@neuroglia.io>
Ok, it seems we have an agreement. Once @cdavernas is done with the DSL refactor, I will open a PR associated to this issue modifying the spec and the examples. |
I'm not necessarily for that change, I don't think that using '$( )' is less confusing than '${ }' or causes less problems, especially with the Plus, like discussed with @ricardozanini, I'd like before we make any decision to get @JBBianchi's input, which will be possible next week or so. Ideally, we should gather as much "opinions" on this to see which one "wins", if any. Maybe setting a small poll? |
@cdavernas It not a question of personal choice. Using {} as markup character in json is confusing and in yaml force you to use '' or additional spaces even when they are not needed. I think the rationale and the example I wrote here was pretty clear. I agree we need to vote, since keeping {} for me is a mistake, not a matter of personal taste |
AFAIK, in YAML you do not have to do anything, because happilly it starts with ${, not simply {. The reasoning behind using mustaches, which people can understandingly be nervous about, is because it's conventionnally used to indicate evaluation. I'm not saying we should/should not use it, - hell, I like your suggestion-, I'm just saying I would like other people opinion before claiming unilaterally that we have an agreement 😛 Can we just wait for start of next week before taking a decision/acting? |
In YAML you need to either use white spaces or quoutes, since { and } are special characters that needs to be esscaped. while ( and ) are is not, thats the whole point (for Yaml, I hope that for json is obvious that {} are a poor choice, the point can be summarized as " do not use as markup characters that are reserved in the language you are using to write the definition") and thats why in the examples I mentioned, you do not need quotes or white spaces anymore. |
I agree we can wait till next week, I was raising the point becuase there is another PR where the ${} appeared (the looss evaluation one) and we need to wait to have an agreement before that PR is merged |
This is valid, with no quotes, no whitespaces: test:
expression: ${ Hello, world } test:
expression: ${Hello, world} Am I missing something? I dont know why you think you had to add the quotes in your examples, as this is valid, too: set:
name: ${input.name} Like I said, it's valid because the line starts with $, which is not a control character, and which makes following ones to be included as a string, whatever they are. |
That PR already was merged, as part of the refactor! I added the loose/strict before pushing it in, based on your/ric's awesome suggestions! |
should be valid because the special character { and } are separated by whitespaces
should not be. If it is, maybe the parser you are using is smart and interpreting that {} are not special character but part of the string because the string does not start with {, but my point still stands, { and } are reserved characters in yaml that should not be used for markup unless there were not any other option, which hopefully exist, because ( and ) are not reserved. And also avoid the uglyness when writing in json. So the advantages of replacing { by ( and } by ) should be clear. This is the yaml spec section I was using https://yaml.org/spec/1.2.2/#742-flow-mappings |
I dont want to be a PITA, especially that, once again, I'm not opposed to the change, but I disagree when you say your point still stands. As a matter of fact, YAML doesnt tell you you shouldnt be using mustaches, it just tells you that if you encounter this token while reading, and before the token has been identified as, say, a string, it should denotate the start of a mapping. If the line starts with, say, $, the token IS a string, and YAML allows you to write whatever you want, including mustaches, semi-colons, dots, which all are other control characters. That fact goes against your point, saying that we can't use { because it's a control character. We are not using '{', we are using '${', which simply works! On a side note to that, I want to remind you mustaches are what Amazon and Google have opted for. I'm not saying, once again, that we should use them, or that this fact is a good reason to use them, I just think that if YAML intended such limitations (which it does not, every linter I tried works without quotes), high chances are they would have chosen other characters. |
if yaml is so smart and you can write everything after the $, then why we write the swith example using quotes |
And now, lets discuss about google workflows
They are using ${} for their expression without qoutes (so it seems ignoring { and } in indeed universal, as you claimed, my bad, I will review the yaml spec to check where that is stated) but they are significantly wrapping string constants within "" (I do not know why do they that) |
@cdavernas Btw, I do not think we are being a PITA. When writing a spec we need to be rigorous. I found this conversation enriching |
I cannot do that, unhappilly, nor could you do the opposite. I'm however open to conceive an interpreter or another might not handle the use case you presented properly. Could you find one that didnt like the ${ ?
That is a very valid point, and is probably the essence of your proposal.
Cool! And so do I! |
I was playing a bit with the current conversion between YAML and JSON that I wrote using Jackson. YAML snippet
is converted to this JSON
This confirms that very likely any yaml parser which found any character before the { will understand that { is not declaring a json |
Also |
@fjtirado do we still need to do anything here, even after adding the |
Currently we can write
or
However $ is a reserved keyword in JQ and {} are used in json, think of this expression written in json
(I wrote it wrong three times :))
I think we should consider following options
This implies user has to escape literals.
Use something different than
${}
for example, use ``We can use a different character, for example,
#
, but with this one we need to add white spaces around the expressionSo after the property name, you expect either
constant
orexpr
and use as defaultexpr
(that default might be overriden by user in the header of the workflow definition)expr
:constant
:The text was updated successfully, but these errors were encountered: