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

Environment variables aren't defined until invocation. #1751

Closed
jthomas opened this issue Jan 23, 2017 · 4 comments
Closed

Environment variables aren't defined until invocation. #1751

jthomas opened this issue Jan 23, 2017 · 4 comments
Assignees
Labels

Comments

@jthomas
Copy link
Member

jthomas commented Jan 23, 2017

Environment details:

IBM Bluemix (US-South).

Steps to reproduce the issue:

This action demonstrates the issue.

var openwhisk = require('openwhisk');

console.log(process.env['__OW_API_KEY']);
// blows up here....
var ow = openwhisk(); 

function main(params) {
   console.log(process.env['__OW_API_KEY']);
  // ...but this would work.
   var ow = openwhisk(); 
  return { message: 'Hello World' };
}

Additional information you deem important:

__OW_API_KEY is not defined until the the invocation occurs.

The user cannot define the openwhisk client outside the handler function without explicitly providing both the api key and host endpoint.

Would it be possible to move the variables apart from deadline and activation_id to the handler init section?

If this isn't possible, this behaviour should be documented.

@jthomas
Copy link
Member Author

jthomas commented Feb 7, 2017

I've just helped another user who ran into this issue. I'm going to add a note to the client library README to call this behaviour out but I can imagine it's going to continue to trip people up.

@sjfink
Copy link
Contributor

sjfink commented Feb 7, 2017

This also seems somewhat related to #1728 -- in general we need to revamp how we initialize global state of all kinds.

I agree that defining _OW_API_KEY during init() for javascript actions seems like a good idea. I can't think of any reason not to.

@homerjam
Copy link

+1

@mrutkows mrutkows self-assigned this Feb 28, 2019
@rabbah
Copy link
Member

rabbah commented Dec 18, 2019

This is now fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants