serverless / compose

Orchestrate Serverless Framework in monorepos
https://serverless.com/framework/docs/guides/compose
MIT License
111 stars 15 forks source link

`${foo:bar}` syntax is confused with `${foo.bar}` syntax #64

Closed mnapoli closed 2 years ago

mnapoli commented 2 years ago
services:
  subscriptions:
    path: subscriptions
    params:
      foo: ${param:bar}

The config above throws the following error:

The service "param:bar" does not exist. It is referenced by "subscriptions" in expression "${param:bar}".

From my debug it seems like this regex matches ${param:bar}, and then this line does not detect that there was no . in the string. So it considers "param:bar" as the service name.

Instead we should get an error that says that param isn't a valid variable source (or something of the sort?).

pgrzesik commented 2 years ago

Thanks for catching that @mnapoli - I'll see what our potential options are 👍

That's also a good point opportunity to bring up the syntax for accessing outputs once again that we briefly discussed here: https://github.com/serverless/compose/issues/21

What do you see as the downside of aiming to use the same syntax as current Framework variables? I think it would be quite beneficial to not have two (in my opinion) syntaxes for achieving something similar.

mnapoli commented 2 years ago

That's also a good point opportunity to bring up the syntax for accessing outputs once again that we briefly discussed here: https://github.com/serverless/compose/issues/21

What do you see as the downside of aiming to use the same syntax as current Framework variables? I think it would be quite beneficial to not have two (in my opinion) syntaxes for achieving something similar.

Not sure what you mean?

To clarify, I'm not saying we should change anything. Just that the error message is confusing/incorrect because it says "The service "param:bar" does not exist" but ${param:xxx} is not the syntax to access a service output.

Or did you mean something else?

pgrzesik commented 2 years ago

Sorry, I've assumed that the error popped up because someone tried to do access output by ${component:output} with : instead of ., I've personally run into that multiple times and assumed this is an instance of the same error.