Closed pdcastro closed 4 years ago
The following code seems relevant:
const ENV_VAR_KEY_REGEX = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
...
if (!ENV_VAR_KEY_REGEX.test(key)) {
log.debug(
`Invalid env var key passed to validation.isValidEnv\nKey: ${inspect(key,}`,
Also (not sure if the change would be in balena-supervisor
or balena-cli
), it would be good to expose the more detailed error message (as above: Invalid env var key passed to validation.isValidEnv
) to the CLI. Currently, what users get is BadRequestDeviceAPIError: Invalid apps
.
Loosely related supervisor issue: #748 Better handle spaces and other special characters in environment variables
I have hit another problem related to special characters. This time with the env value.
again in local mode this returns an error
balena push --env POSTGRESQL_DSN=postgres://loraserver_ns:59XTH2995@postgresql/loraserver_ns?sslmode=disable 192.168.10.103
tried escaping, quotes etc, but nothing worked. I have now added a workaround(modified the golang app a bit), but I am thinking the proper soltuion should be that adding quotes should be enough to not cause problems with any special characters.
relevant docker compose entry
loraserver:
image: arribada/loraserver
environment:
- REDIS_URL=redis://redis:6379
- NETWORK__SERVER_BAND_NAME=EU_863_870
- NETWORK__SERVER_GATEWAY_BACKEND_MQTT_SERVER=tcp://mosquitto:1883
- JOIN__SERVER_DEFAULT_SERVER=http://appserver:8003
- GEOLOCATION__SERVER_SERVER=geoserver:8005
https://github.com/brocaar/lora-app-server/issues/369
Had a reply upstream that using dots in the env names should be removed so the only issue now is that the env value can't contain :
which is needed in the POSTGRESQL_DSN env variable
loraserver doesn't need dots in the env vars now so only :
should be added.
@krasi-georgiev the value of the environment variable can contain :
, that isn't an issue, this issue is related to the variable names. If you're having problems with the value of environment variables, could you make an issue please?
are you saying that something like this works for you?
balena push --env POSTGRESQL_DSN=postgres://loraserver_ns:59XTH2995@postgresql/loraserver_ns?sslmode=disable 192.168.10.103
the original issues was for dots in the env names, but dots in env vars is not valid in the Unix systems anyway so the fact the compose supports it was probably just an overlook.
@krasi-georgiev I did a little investigation, and this is actually an issue with the CLI parsing command line arguments, the supervisor is more than happy to accept this.
I've created an issue you can track here: https://github.com/balena-io/balena-cli/issues/1705 and a workaround would be to provide these env vars in your docker-compose.yml.
I'm going to close this issue, because as you say, dots in env names aren't allowed in Unix systems.
As originally reported in the CLI repo: https://github.com/balena-io/balena-cli/issues/1446
returns an error:
the same works running it locally with