Why Can't I Select a Key as a Secret Prop in My Programming Code?

This topic was automatically generated from Slack. You can find the original thread here.

I can’t seem to select a key as a secret prop:

I created a variable as a secret, and I created a prop to pass in that key. But when I select on it, I don’t see anything.

could you share you node.js code that declare the prop?

yep (note this is different from the inability to test and debug nodes):

export default defineComponent({
props: {
api_key: {
type: “string”,
label: “Cartesia API Key”,
description: “Your Cartesia API key”,
secret: true,
},
model_id: {
type: “string”,
label: “Model ID”,
description: “Cartesia model ID (e.g., zonos-v0.1-transformer)”,
default: “sonic-2”,
},
// Make these optional since they can come from previous steps
transcript: {
type: “string”,
label: “Transcript”,
description: “The text to convert to speech”,
optional: false,
},
voice_id: {
type: “string”,
label: “Voice ID”,
description: “The ID of the voice to use”,
optional: false,
},
language: {
type: “string”,
label: “Language”,
description: “Language code (e.g., en)”,
default: “en”,
}
},

Hey , it seems to work normally on my side (see image below)

In order to reproduce your issue, could you share mode details on how you exported your API Key?

On another note, is it possible for you to store the API Key in Pipedream Environment Variables instead? Pipedream Environment Variables is the recommended way to store secret: GitHub

I’m a little confused, this section should not be used for environment variables?

Yes it is environment variable, but you’ll need to use it in your code

const url = `http://yourapi.com/endpoint/?api_key=${process.env.API_KEY}`;

Oh, you mean versus via the prop?

Hm, I am rebuilding everything by scratch now and I was able to get it to accept the path via the prop…but the code is the same as far as I can tell

I don’t understand why this doesn’t seem to work consistently…when I first set it up, it works, but then … it doesn’t do anything:

okay I figured it out…It needs to be cleared and then I can add a value

I believe it is because you’re using the env var via prop. You’ll need to update your code to use the env directly, such as:

// To use any npm package, just import it
// import axios from "axios"

export default defineComponent({
  async run({ steps, $ }) {
    // Reference previous step data using the steps object and return data to use it in future steps
    return process.env.TEST_VAR_1
  },
})

I logged the header being constructed and it is including the API key value set in prop…

Oh okay , is there an action missing on Pipedream side that requires you to use Code step instead? If so, you can submit a ticket on GitHub > Action Request to request for the new action, we’ll prioritize to implement the feature