It happens when you retrieve a Secret separately in each mapped task. There are two ways to solve it:
- Changing the flow structure so that Secret is retrieved only once and passed to the mapped task as
- Adding the Secret additionally to storage as shown below
@Ryan_Brennan: Hi All - I’m running into a weird issue with Secrets. Sometimes a task will fail with the error message below even though the Secret is stored correctly in the tenant:
KeyError('The secret <SECRET NAME> was not found. Please ensure that it was set correctly in your tenant
This seems to happen the most when I’m using task mapping but it seems pretty random. 100 iterations of the mapped task will work, then the 101st fails with the error above, then the next 100 are successful. Has anyone ran into this issue or have any ideas on what might be happening?
@Kevin_Kho: Hey @Ryan_Brennan, this is because the Secret is an API call and this is an API call failing (maybe rate limiting). It would help if you add the secret to storage ahead of that so that it’s only pulled once.
flow.storage = Storage(…,secrets=[…])
@Ryan_Brennan: Oh awesome! thanks for the quick response @Kevin_Kho