Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Readable validation on the apps engine environment bridge #12994

Merged
merged 2 commits into from
Dec 19, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions packages/rocketchat-apps/server/bridges/environmental.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ export class AppEnvironmentalVariableBridge {
async getValueByName(envVarName, appId) {
console.log(`The App ${ appId } is getting the environmental variable value ${ envVarName }.`);

if (this.isReadable(envVarName, appId)) {
return process.env[envVarName];
if (!(await this.isReadable(envVarName, appId))) {
throw new Error(`The environmental variable "${ envVarName }" is not readable.`);
}

throw new Error(`The environmental variable "${ envVarName }" is not readable.`);
return process.env[envVarName];
}

async isReadable(envVarName, appId) {
Expand All @@ -23,10 +23,10 @@ export class AppEnvironmentalVariableBridge {
async isSet(envVarName, appId) {
console.log(`The App ${ appId } is checking if the environmental variable is set ${ envVarName }.`);

if (this.isReadable(envVarName, appId)) {
return typeof process.env[envVarName] !== 'undefined';
if (!(await this.isReadable(envVarName, appId))) {
throw new Error(`The environmental variable "${ envVarName }" is not readable.`);
}

throw new Error(`The environmental variable "${ envVarName }" is not readable.`);
return typeof process.env[envVarName] !== 'undefined';
}
}