Unable to set environment variables through the CLI

When running the command balena envs --application MyApplication I get the following error:

BalenaRequestError: Request error: Internal Server Error
at /snapshot/balena-cli/node_modules/balena-request/build/request.js:197:17
at tryCatcher (/snapshot/balena-cli/node_modules/bluebird/js/release/util.js:16:23)
at Promise.module.exports.Promise._settlePromiseFromHandler (/snapshot/balena-cli/node_modules/bluebird/js/release/promise.js:512:31)
at Promise.module.exports.Promise._settlePromise (/snapshot/balena-cli/node_modules/bluebird/js/release/promise.js:569:18)
at Promise.module.exports.Promise._settlePromise0 (/snapshot/balena-cli/node_modules/bluebird/js/release/promise.js:614:10)
at Promise.module.exports.Promise._settlePromises (/snapshot/balena-cli/node_modules/bluebird/js/release/promise.js:694:18)
at _drainQueueStep (/snapshot/balena-cli/node_modules/bluebird/js/release/async.js:138:12)
at _drainQueue (/snapshot/balena-cli/node_modules/bluebird/js/release/async.js:131:9)
at Async._drainQueues (/snapshot/balena-cli/node_modules/bluebird/js/release/async.js:147:5)
at Immediate.e.Async.drainQueues (/snapshot/balena-cli/node_modules/bluebird/js/release/async.js:17:14)
at runCallback (timers.js:672:20)
at tryOnImmediate (timers.js:645:5)
at processImmediate [as _immediateCallback] (timers.js:617:5)

I also get another error if I try adding an new environment variable with balena env add DEBUG 1 --application MyApplication:

BalenaRequestError: Request error: Database error
at /snapshot/balena-cli/node_modules/balena-request/build/request.js:197:17
at tryCatcher (/snapshot/balena-cli/node_modules/bluebird/js/release/util.js:16:23)
at Promise.module.exports.Promise._settlePromiseFromHandler (/snapshot/balena-cli/node_modules/bluebird/js/release/promise.js:512:31)
at Promise.module.exports.Promise._settlePromise (/snapshot/balena-cli/node_modules/bluebird/js/release/promise.js:569:18)
at Promise.module.exports.Promise._settlePromise0 (/snapshot/balena-cli/node_modules/bluebird/js/release/promise.js:614:10)
at Promise.module.exports.Promise._settlePromises (/snapshot/balena-cli/node_modules/bluebird/js/release/promise.js:694:18)
at _drainQueueStep (/snapshot/balena-cli/node_modules/bluebird/js/release/async.js:138:12)
at _drainQueue (/snapshot/balena-cli/node_modules/bluebird/js/release/async.js:131:9)
at Async._drainQueues (/snapshot/balena-cli/node_modules/bluebird/js/release/async.js:147:5)
at Immediate.e.Async.drainQueues (/snapshot/balena-cli/node_modules/bluebird/js/release/async.js:17:14)
at runCallback (timers.js:672:20)
at tryOnImmediate (timers.js:645:5)
at processImmediate [as _immediateCallback] (timers.js:617:5)

Hi ,
can you please run balena version so that we know what version of the cli you are using ?
Regards
Thomas

I am currently using 10.13.4, but the problem persisted when I downgraded to 10.13.3

This issue seems to be fixed in openBalena v1.2.0.

Just tried it on Ubuntu with version 10.13.4 - it works for me.
I have seen issues with spaces in variable names in the past - can you check that your ENV variable names do not contain spaces ? They can easily hide at the end…
Otherwise what OS are you running balena on ?

I’m currently on Ubuntu 18.04. I only have one environment variable that I was able to set before, so this issue seems to have just randomly appeared due to some outside factor.

Ok same here so it is more likely connected to your application rather than to the cli version …

Have you taken a look at your variable and made sure no spaces have got into the name ?

I checked all my variables, seems like some kind of fluke. Maybe there was a version mismatch between the CLI and openBalena.

@kirkbrauer, indeed it was fixed. Do you still have issues setting env vars?

Everything seems to be fixed on my end. Thanks for the support.