I'm going crazy, I'm trying to pull a secret in a ...
# prefect-community
j
I'm going crazy, I'm trying to pull a secret in a class task, and the type it returns is
<class 'prefect.configuration.Config'>
and I have no idea why. Did I do something wrong in the
config.toml
file??
j
Hi Jacobo, would you mind sharing an example configuration and the code you're using to pull in a secret that results in this behavior?
👀 1
j
Let me get back to you, thanks for responding.
The code is inside of a Task definition as shown below. The idea is to connect to GoogleSheets using the task (I realize there's one in the library already but our internal ones contain more specific functionality) :
Copy code
from prefect import Task
from prefect.tasks.secrets import PrefectSecret
from prefect.utilities.tasks import defaults_from_attrs
from typing import Any, List

class ConnectToGoogleSheets(Task):
    def __init__(self, account_key: str = None, **kwargs: Any):
        self.account_key = account_key

        super().__init__(**kwargs)

    def run(self, **kwargs: Any):
        if not self.account_key:
            raise ValueError("The account key string must be provided")

        account_key_actual = PrefectSecret(self.account_key).run()
        
        print(type(account_key_actual))

        ....
There's more code in the task definition but the type that gets returned is Config.