Hey folks, having some persistent issues with the ...
# ask-community
j
Hey folks, having some persistent issues with the Secrets Vault. In a mapped task with 20 tasks, for some reason 1 out of the 20 mapped runs might error out complaining that Secret A is not available even though the other 19 found Secret A before and after the failing task.
a
@Jacob Blanco that’s unusual. Perhaps you could retrieve this secret only once and pass it to the mapped tasks as “unmapped” data dependency?
👍 1
here is an example:
Copy code
from prefect import task, Flow, unmapped
from prefect.tasks.secrets import PrefectSecret


@task
def say_hi(user_name, secret):
    print(f"Hi {user_name}")


with Flow("unmapped_serets"):
    credential = PrefectSecret("SOME_SECRET")
    list_names = ["Jacobo", "Marvin"]
    say_hi.map(list_names, secret=unmapped(credential))
k
I think you can also try adding it to storage.
Copy code
flow.storage = SomeStorage(..., secrets=["SECRET_NAME"])
to reduce the API calls
upvote 1
m
or set retries to secret task
Copy code
secret_task = PrefectSecret(
    max_retries=5,
    retry_delay=datetime.timedelta(seconds=5),
)
k
Hahaha that’s clever @Marko Herkaliuk
🙏 1