DrFaust92 / terraform-provider-bitbucket

Terraform Bitbucket Cloud provider.
https://registry.terraform.io/providers/drfaust92/bitbucket
Mozilla Public License 2.0
36 stars 29 forks source link

HTTP 400 updating `bitbucket_project` #73

Open matthewhartstonge opened 2 years ago

matthewhartstonge commented 2 years ago

Terraform Version

Terraform v1.1.9
on windows_amd64
+ provider registry.terraform.io/drfaust92/bitbucket v2.17.0

Affected Resource(s)

Please list the resources as a list, for example:

Possible other resources with link.avatar.href ?

Terraform Configuration Files

data "bitbucket_workspace" "example_workspace" {
  workspace = "example-workspace"
}

resource "bitbucket_project" "examples" {
  owner       = data.bitbucket_workspace.example_workspace.slug
  name        = "Examples"
  key         = "EX"
  description = "Example code."
  is_private  = true
  link {
    avatar {
      href = "https://example.com/examples.png"
    }
  }

Debug Output

╷
│ Error: error updating project (example/EX): 400 Bad Request
│ 
│   with bitbucket_project.examples,
│   on bitbucket_projects.tf line 40, in resource "bitbucket_project" "examples":
│   40: resource "bitbucket_project" "examples" {
│ 
╵

The diff suppression will always suppress once an image is configured for the Project i.e. no updates ever as the URI returned from bitbucket will always contain https://bitbucket.org/account/user.

image

This of course leads to the image never being picked up as needing to be updated under the Terraform diff:

image

Regardless, the update payload always sends the old Bitbucket image URL, which Bitbucket rejects as the URL doesn't have a filename ending in {jpeg, png, gif}

image

Modding the client library I extracted the returned HTTP 400 response body:

image

Panic Output

If Terraform produced a panic, please provide a link to a GitHub Gist containing the output of the crash.log.

N/A

Expected Behavior

Actual Behavior

HTTP 400 Bad request - as the Bitbucket API doesn't support image uri's without a {.png, .jpeg, .gif} ending.

╷
│ Error: error updating project (linced/EX): 400 Bad Request
│ 
│   with bitbucket_project.examples,
│   on bitbucket_projects.tf line 40, in resource "bitbucket_project" "examples":
│   40: resource "bitbucket_project" "examples" {
│ 
╵

Steps to Reproduce

Important Factoids

References

Are there any other GitHub issues (open or closed) or Pull Requests that should be linked here? For example:

  • GH-1234

No.

DrFaust92 commented 2 years ago

Thanks matthewhartstonge ill try to take a look at this as soon as i can

matthewhartstonge commented 2 years ago

Having a think about this - If we stored a "private" read-only computed schema property we should be able to check if the strings have changed internally.

renatomjr commented 1 year ago

Hi @matthewhartstonge. Did you find some workaround to at least complete the apply? I'm stuck on this.

matthewhartstonge commented 1 year ago

Hi @renatomjr, no - we ended up migrating our organisation to Github not too long after so didn't have to worry about this..

image

smavrokef commented 1 year ago

Hi! @DrFaust92 is there any update on this? Currently its impossible to apply any changes after creation/import.

DrFaust92 commented 8 months ago

Opened a temp fix that would ignore avatar on update to allow to use project. ill try to fix avatar update as well

hoo29 commented 3 weeks ago

Hi @DrFaust92 - did you have any luck fixing the avatar updating?