I am getting an error with Prefect Secrets in my f...
# prefect-community
I am getting an error with Prefect Secrets in my flow. The traceback is to a line of Prefect code that was changed a few days ago. The traceback can be found in the thread below. This is what the task in the flow looks like:
Copy code
gcs_creds_secret = PrefectSecret("GCS_SP_CREDS")
Hi @Zach - let me see if I can find out a bit more about this. Would you mind moving the traceback into the thread here? (Short messages make it easier for us to keep on top of all the community messages.)
No problem, here you go:
Copy code
Unexpected error: AttributeError("'PrefectSecret' object has no attribute 'secret_name'")
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/prefect/engine/runner.py", line 48, in inner
    new_state = method(self, state, *args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/prefect/engine/task_runner.py", line 856, in get_task_run_state
    value = prefect.utilities.executors.run_task_with_timeout(
  File "/usr/local/lib/python3.8/dist-packages/prefect/utilities/executors.py", line 298, in run_task_with_timeout
    return task.run(*args, **kwargs)  # type: ignore
  File "/usr/local/lib/python3.8/dist-packages/prefect/tasks/secrets/base.py", line 65, in run
    name = self.secret_name
AttributeError: 'PrefectSecret' object has no attribute 'secret_name'
👍 1
@Jenny I am not 100% sure how task run methods work, but it seems like in general, the run() method doesn't have access to class instance variables that were set in the
method,. Not sure why that is though. But it seems in the run method here, the code tries to access this class instance variable and it fails.
What are you running that encounters this error? I seem to be able to access the secret 🤔
Copy code
In [1]: from prefect.tasks.secrets import PrefectSecret

In [2]: PrefectSecret("TEST")
Out[2]: <Task: TEST>

In [3]: PrefectSecret("TEST").run()
Out[3]: 'asdf\nhere'
Are you by any chance building your flow in a newer version of prefect and attempting to run it in an older one?