Workflow with environment variable mysteriously became undefined

Hello,

I have a workflow that references an API key in process.env. It works fine in testing the workflow and it used to work when it gets triggered by the schedule trigger, however it now shows up as undefined in the workflow when triggered by the schedule trigger. What could have happened?

Error was process.env needs to be accessed within “async run({ steps, $ }) {” on trigger, but it doesn’t during testing the individual code step.

1 Like

@nerd-of-iron Thanks for reaching out. I wasn’t able to reproduce this - referencing process.env within a Node.js code step, and testing that step individually, produces the environment variable data I expect.

Are you able to share the code that failed to work for you?

From the code step, this works in both testing the individual code step and testing/deploying the workflow:


// To use previous step data, pass the `steps` object to the run() function
export default defineComponent({
    const apiKey = process.env.API_KEY;

This works only in testing the individual code step:


const apiKey = process.env.API_KEY;
// To use previous step data, pass the `steps` object to the run() function
export default defineComponent({