trapeze icon indicating copy to clipboard operation
trapeze copied to clipboard

Error when parsing strings as environment variables

Open leo-jnesis opened this issue 3 years ago • 2 comments

Steps to reproduce :

  • add a var in your config file without default value :
vars:
  SOME_VERSION:

platform:
  android: 
    versionName: $SOME_VERSION
  • run SOME_VERSION="1.2.3" npx trapeze

You should get this error :
Unable to parse environment variable SOME_VERSION SyntaxError: Unexpected token . in JSON at position 3

This is because we automatically try to parse the variable value as JSON here : https://github.com/ionic-team/trapeze/blob/cfaeaf892e1565ebb0462d1049ecf9005e0cfe0a/packages/configure/src/ctx.ts#L106

leo-jnesis avatar Aug 09 '22 18:08 leo-jnesis

this won't work if the string you provide is not numeric or JSON formatted

leo-jnesis avatar Aug 09 '22 19:08 leo-jnesis

as a workaround : running SOME_VERSION='"1.2.3"' npx trapeze works

leo-jnesis avatar Aug 10 '22 08:08 leo-jnesis

@mlynch @leo-jnesis I don't understand why we get these errors if it's a simple string value?

Screenshot 2022-09-27 at 21 56 07

maybe log this is set flag DEBUG=true?

https://github.com/ionic-team/trapeze/blob/c1c7c81a566fec0f327e63b55d811a1b1e5a32b0/packages/configure/src/ctx.ts#L110

reslear avatar Sep 27 '22 19:09 reslear

@reslear yea good point. I tweaked the logging a bit in 5.0.6, freshly released

mlynch avatar Sep 30 '22 16:09 mlynch