#Need Help with Dagger CLI: Error - Secret Not Found

1 messages ยท Page 1 of 1 (latest)

strong palm
#

Hello,

I'm currently using the Dagger CLI to set a secret and retrieve it, but I encountered an error saying "Error: secret not found." I've included the script I'm using below. Could you please help me identify what might be going wrong?

Thank you!

#!/usr/bin/env bash

REGISTRY_PASSWORD="monsecret"


registry_secret_id=$(dagger query <<QUERY | jq -r '.setSecret.id'
{
   setSecret(name: "registry-password", plaintext: "$REGISTRY_PASSWORD") {
     id
   }
}
QUERY
)
echo -e "$registry_secret_id"

dagger query <<QUERY
{
  secret(id: "$registry_secret_id") {
    plaintext
  }
}
QUERY
sweet totem
#

๐Ÿ‘‹ this is because secrets are only re-usable withing the same dagger session. Since you're running dagger query twice, that creates two different sessions.

If you run dagger run <your_script.sh> that will make both dagger query to use the same session since the session is started by dagger run

#

hmm just realized dagger query doesn't re-use the same session if it exists.. probably a defect from our side

#

checking with @feral stream just to validate dagger query should re-use a session if invoked with dagger run

feral stream
sweet totem
#

@strong palm what you can do in the meantime is follow this approach Helder described in another post of replacgin dagger query with a query function that just uses curl to call the graphql API. #1110544435781050418 message

feral stream
sweet totem
feral stream
#

right now they're all session bootstrappers ๐Ÿ˜› (there's also dagger session and dagger listen)

strong palm
#

so does it mean I cannot use secrets?

feral stream
#

not with dagger query. Is there a reason you're not using a SDK? Maybe it's not supported for your preferred language?

strong palm
#

it's supported by my preferred language but it's not by the team i'm working with

sweet totem
strong palm
#

I have done every steps I needed but one which is to publish to the registry and I need to authenticate this is why i needed to use secret

feral stream
#

just trying to understand, it seems to me like using any language would be better than scripting GraphQL APIs with bash haha

strong palm
#

I agree but if I start doing it in go or python nobody is going to maintain it

#

alright, thank you for your help

sweet totem
#

I'll open an issue to make dagger query re-use a session if it exists

strong palm
#

I used curl and it's working... thank you