User defined variable "key" validation doesn't happen at cf set-env phase


Ponraj E
 

Hi CF Colleagues,

I see various PaaS providers provide the UI for entering the User provided variables' key and value, but they dont seem to validate the "key" at the save ["set-env"] phase, the validation happens only at
the restage phase. This is also because CF does the same. Is there any reason that CC doesnt validate keys of user defined environment varibles at the cf set-env phase ?

Examples:
1.cf set-env spring-music !@#$$%% "foobar" succeeds, but the restage fails throwing /bin/bash: line 6: export: `!@#49%%=foobar': not a valid identifier
2.cf set-env spring-music "!@#$$%%" "foobar" succeeds, the restage also succeeds but the same as above is thrown as message here.

P.S: The above variables are used for only testing purposes and these would give errros at the runtime usage in the application is implicit here.


Regards,
Ponraj


Nicholas Calugar
 

Hi Ponraj,

I don't think the CC can make any determination regarding the validity of
environment variables as the CC doesn't (and shouldn't) know how each
buildpack will use these environment variables.

Thanks,

Nick

On Thu, Mar 3, 2016 at 9:22 AM Ponraj E <ponraj.e(a)gmail.com> wrote:

Hi CF Colleagues,

I see various PaaS providers provide the UI for entering the User provided
variables' key and value, but they dont seem to validate the "key" at the
save ["set-env"] phase, the validation happens only at
the restage phase. This is also because CF does the same. Is there any
reason that CC doesnt validate keys of user defined environment varibles at
the cf set-env phase ?

Examples:
1.cf set-env spring-music !@#$$%% "foobar" succeeds, but the restage
fails throwing /bin/bash: line 6: export: `!@#49%%=foobar': not a valid
identifier
2.cf set-env spring-music "!@#$$%%" "foobar" succeeds, the restage also
succeeds but the same as above is thrown as message here.

P.S: The above variables are used for only testing purposes and these
would give errros at the runtime usage in the application is implicit here.


Regards,
Ponraj


Padmashree B
 

Hi Nick,

Thanks for the clarification!
But as a developer I would expect the restart/restage of the application fails if the environment variables is invalid.
However, this is not the case always - if the var name has special characters such as @$ etc., it fails to restart, the user can then trouble-shoot to find the issue.
But in cases where the var name has . or -, the application restarts/restages successfully. The app logs, however, contains ERR message
ERR /bin/bash: line 17: export: `test-dash=testing special chars': not a valid identifier
At runtime, these invalid variables are not accessible by the application.

As a developer, I would expect, the application fails at an early stage during restart.

Kind Regards,
Padma