https://prefect.io logo
Title
k

kevin

08/16/2021, 6:29 PM
hey guys, if I want to check for the existence of a secret, is the best way to do that through
prefect.context.get('<SECRET NAME>')
or should I use the
Secret()
class?
k

Kevin Kho

08/16/2021, 6:35 PM
Hey @kevin, I think it would be
Secret().get()
because the first one means it’s in context already (and cloud secrets might not be there).
For local secrets on server, the context might work
k

kevin

08/16/2021, 6:36 PM
Secret().get()
will throw a KeyError if the secret doesn't exist right? So i can manage it like a normal python exception?
or is there something I should be aware of?
k

Kevin Kho

08/16/2021, 6:37 PM
Yes that’s exactly right I think
k

kevin

08/16/2021, 6:37 PM
sounds good, appreciate the response 🙂
👍 1