Skip to content
This repository has been archived by the owner on Dec 8, 2020. It is now read-only.

'404 pipelines_config Not found' when importing bitbucket_repository without Pipelines enabled #58

Open
tdmalone opened this issue May 31, 2020 · 3 comments

Comments

@tdmalone
Copy link

Terraform Version

$ terraform version
Terraform v0.11.14
+ provider.bitbucket v1.2.0

Affected Resource(s)

Please list the resources as a list, for example:

Terraform Configuration Files

resource "bitbucket_repository" "my_repo" {
  owner = "my-team"
  name  = "my-repo"
}

Expected Behavior

Terraform should have imported my-repo without errors.

Actual Behavior

$ terraform import bitbucket_repository.my_repo my-team/my-repo
bitbucket_repository.my_repo: Importing from ID "my-team/my-repo"...
bitbucket_repository.my_repo: Import complete!
  Imported bitbucket_repository (ID: my-team/my-repo)
bitbucket_repository.my_repo: Refreshing state... (ID: my-team/my-repo)

Error: bitbucket_repository.my_repo (import id: my-team/my-repo): 1 error occurred:
        * import bitbucket_repository.my_repo result: my-team/my-repo: bitbucket_repository.my_repo: API Error: 404 2.0/repositories/my-team/my-repo/pipelines_config Not found

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. Use the config provided above, but adjust to a team name and repo you have access to
  2. terraform import bitbucket_repository.my_repo my-team/my-repo

Important Factoids

@elpy1
Copy link

elpy1 commented Sep 1, 2020

Just ran into this. Appears to be an issue with the bitbucket API, not the terraform provider?

Initial API response using /2.0/repositories/{workspace}/{repo_slug}/pipelines_config [0]:

{
    "type": "error",
    "error": {
        "message": "Resource not found",
        "detail": "There is no API hosted at this URL.\n\nFor information about our API's, please refer to the documentation at: https://developer.atlassian.com/bitbucket/api/2/reference/"
    }
}

After manually enabling pipelines:

{
    "repository": {
        "name": "My Repo",
        "type": "repository",
        "full_name": "ownerofrepo/this-is-my-repo",
        "links": {
            "self": {
                "href": "https://api.bitbucket.org/2.0/repositories/ownerofrepo/this-is-my-repo"
            },
            "html": {
                "href": "https://bitbucket.org/ownerofrepo/this-is-my-repo"
            },
            "avatar": {
                "href": "https://google.com/lol.jpg"
            }
        },
        "uuid": "{exxxxxa5-e062-4xxc-axx7-346xxxxxxe78}"
    },
    "enabled": true,
    "type": "repository_pipelines_configuration"
}

After manually disabling pipelines:

{
    "repository": {
        "name": "My Repo",
        "type": "repository",
        "full_name": "ownerofrepo/this-is-my-repo",
        "links": {
            "self": {
                "href": "https://api.bitbucket.org/2.0/repositories/ownerofrepo/this-is-my-repo"
            },
            "html": {
                "href": "https://bitbucket.org/ownerofrepo/this-is-my-repo"
            },
            "avatar": {
                "href": "https://google.com/lol.jpg"
            }
        },
        "uuid": "{exxxxxa5-e062-4xxc-axx7-346xxxxxxe78}"
    },
    "enabled": false,
    "type": "repository_pipelines_configuration"
}

It appears the API simply returns a 404 until the pipeline setting is first used.

[0] https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/{workspace}/{repo_slug}/pipelines_config

@tdmalone
Copy link
Author

tdmalone commented Sep 1, 2020

Appears to be an issue with the bitbucket API, not the terraform provider?

Possibly, but it's essentially a bug in the Terraform provider as it breaks importing - so needs a workaround to possibly ignore the error when pipelines aren't enabled.

@joetjef
Copy link

joetjef commented Sep 22, 2020

Just encountered the same error when renaming a repository which has no pipeline and I guess the same will happen if you change any other attribute. This makes this provider unusable if you don't use pipelines.

Temporary fix is to pin the provider to 1.1, then everything works fine but you'll be missing a few features (see change log for more info).

I'm not familiar with go but it looks like that the provider should capture the 404 error and treat it as that the pipelines are disabled.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants