https://prefect.io logo
Title
y

YSF

03/22/2023, 9:45 PM
Hi I'm trying to use a bitbucket storage block with a private repo. I've setup a bitbucket credentials block which is authenticated like this, using username and password. Then I use that inside a bitbucket repository block. But I get this error:
token = self.bitbucket_credentials.token.get_secret_value() AttributeError: 'NoneType' object has no attribute 'get_secret_value'
does anyone have any ideas? The blocks UI does suggest personal access token is optional. Unless it's 'optional' in case it's a public repo
1
n

Nate

03/23/2023, 4:44 PM
it looks like from this that the token is required for private repos, we should probably say that in the field description as well as handle this error better - thanks for raising!
def _create_repo_url(self) -> str:
        """Format the URL provided to the `git clone` command.

        For private repos:
        <https://x-token-auth>:<access-token>@bitbucket.org/<user>/<repo>.git
        All other repos should be the same as `self.repository`.
        """
        url_components = urlparse(self.repository)
        if url_components.scheme == "https" and self.bitbucket_credentials is not None:
            token = self.bitbucket_credentials.token.get_secret_value()
            updated_components = url_components._replace(
                netloc=f"x-token-auth:{token}@{url_components.netloc}"
            )
            full_url = urlunparse(updated_components)
        else:
            full_url = self.repository

        return full_url
y

YSF

03/24/2023, 4:36 AM
Thanks!