Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repository provider retruning HTTP response status 404 error when resources exist #1140

Open
Osazz opened this issue Nov 28, 2024 · 5 comments
Assignees
Labels
blocked Blocked by dependent ticket bug Something isn't working

Comments

@Osazz
Copy link

Osazz commented Nov 28, 2024

Describe the bug
I have a docker remote and virtual repository been managed by Terraform. (resource has been created).

Time to modify something as easy as the description and Terraform is retuning a HTTP response status 404:Failed to execute add project resource with error Could not find project error.

This behaviour is confirmed for both remote and virtual docker repository and Conan remote repository

Even though terraform failed, modification was still applied in the artifactory

Version Information

Artifactory: 7.101.2
Terraform : 1.9.8
Terraform provider Version: 12.5.1

terraform {
  # Restrict this module to require Terraform 1.5 or higher
  required_version = ">= 1.5"

  required_providers {
    artifactory = {
      source  = "jfrog/artifactory"
      version = "~> 12.0"
    }
  }
}

resource "artifactory_remote_docker_repository" "repository" {
  description                       = "Amazon ECR Public Gallery test"
  key                 = "aws-ecr-registry-delete-me"
  url                      = "https://gallery.ecr.aws"
  assumed_offline_period_secs     = 300
  metadata_retrieval_timeout_secs = 60
  missed_cache_period_seconds     = 1800
  retrieval_cache_period_seconds  = 7200
  property_sets                   = ["artifactory"]
}

Terraform Error

artifactory_remote_conan_repository.repository[0]: Modifying... [id=deleteme-conan-remote]
╷
│ Error: {
│   "errors" : [ {
│     "status" : 400,
│     "message" : "HTTP response status 404:Failed to execute add project resource with error Could not find project ``"
│   } ]
│ }
│
│   with artifactory_remote_conan_repository.repository[0],
│   on main.tf line 45, in resource "artifactory_remote_conan_repository" "repository":
│   45: resource "artifactory_remote_conan_repository" "repository" {
│
╵

More Debug log maybe this will be helpful

More Debug Log
2024-11-28T11:40:10.968-0400 [WARN]  Provider "registry.terraform.io/jfrog/artifactory" produced an invalid plan for artifactory_remote_docker_repository.repository[0], but we are tolerating it because it is using the legacy plugin SDK.
    The following problems may be the cause of any confusing errors from downstream operations:
      - .cdn_redirect: planned value cty.False for a non-computed attribute
      - .priority_resolution: planned value cty.False for a non-computed attribute
      - .download_direct: planned value cty.False for a non-computed attribute
      - .query_params: planned value cty.StringVal("") for a non-computed attribute
      - .notes: planned value cty.StringVal("") for a non-computed attribute
      - .bypass_head_requests: planned value cty.False for a non-computed attribute
      - .curated: planned value cty.False for a non-computed attribute
      - .local_address: planned value cty.StringVal("") for a non-computed attribute
      - .disable_proxy: planned value cty.False for a non-computed attribute
      - .disable_url_normalization: planned value cty.False for a non-computed attribute
      - .enable_cookie_management: planned value cty.False for a non-computed attribute
      - .store_artifacts_locally: planned value cty.True for a non-computed attribute
      - .hard_fail: planned value cty.False for a non-computed attribute
      - .project_id: planned value cty.StringVal("") for a non-computed attribute
      - .username: planned value cty.StringVal("") for a non-computed attribute
      - .allow_any_host_auth: planned value cty.False for a non-computed attribute
      - .archive_browsing_enabled: planned value cty.False for a non-computed attribute
      - .proxy: planned value cty.StringVal("") for a non-computed attribute
      - .socket_timeout_millis: planned value cty.NumberIntVal(15000) for a non-computed attribute
      - .blacked_out: planned value cty.False for a non-computed attribute
      - .includes_pattern: planned value cty.StringVal("**/*") for a non-computed attribute
      - .mismatching_mime_types_override_list: planned value cty.StringVal("") for a non-computed attribute
      - .project_key: planned value cty.StringVal("") for a non-computed attribute
      - .remote_repo_layout_ref: planned value cty.StringVal("") for a non-computed attribute
      - .content_synchronisation: block count in plan (1) disagrees with count in config (0)
artifactory_remote_docker_repository.repository[0]: Modifying... [id=aws-ecr-registry-delete-me]
2024-11-28T11:40:10.968-0400 [INFO]  Starting apply for artifactory_remote_docker_repository.repository[0]
2024-11-28T11:40:10.968-0400 [DEBUG] artifactory_remote_docker_repository.repository[0]: applying the planned Update change
2024-11-28T11:40:10.996-0400 [WARN]  unexpected data:
  registry.terraform.io/jfrog/artifactory:stderr=
  | 2024/11/28 11:40:10.996637 DEBUG RESTY
  | ==============================================================================
  | ~~~ REQUEST ~~~
  | POST  /artifactory/api/system/usage  HTTP/1.1
  | HOST   : priv.jfrog.io
  | HEADERS:
  | \tAccept: */*
  | \tAuthorization: <REDACTED>
  | \tContent-Type: application/json
  | \tUser-Agent: jfrog/terraform-provider-artifactory/12.5.1
  | BODY   :
  | {
  |    "productId": "terraform-provider-artifactory/12.5.1",
  |    "features": [
  |       {
  |          "featureId": "Partner/ACC-007450"
  |       },
  |       {
  |          "featureId": "Terraform/1.9.8"
  |       }
  |    ]
  | }
  |
  | ------------------------------------------------------------------------------
  | ~~~ RESPONSE ~~~
  | STATUS       : 200
  | PROTO        : HTTP/1.1
  | RECEIVED AT  : 2024-11-28T11:40:10.996623-04:00
  | TIME DURATION: 42.382208ms
  | HEADERS      :
  | \tConnection: keep-alive
  | \tContent-Length: 0
  | \tDate: Thu, 28 Nov 2024 15:40:11 GMT
  | \tStrict-Transport-Security: max-age=31536000; includeSubDomains
  | \tX-Artifactory-Id: eccbaac55cf86c6eafbb2f82e5782725ac7d6dab
  | \tX-Artifactory-Node-Id: privtr

2024-11-28T11:40:10.996-0400 [WARN]  unexpected data:
  registry.terraform.io/jfrog/artifactory:stderr=
  | ust-artifactory-primary-0
  | \tX-Jfrog-Version: Artifactory/7.101.2 710102900
  | \tX-Request-Id: 5fa072a20ea3fcd8bdd1de366a6d84c0
  | BODY         :
  | ***** NO CONTENT *****
  | ==============================================================================

2024-11-28T11:40:11.038-0400 [WARN]  unexpected data:
  registry.terraform.io/jfrog/artifactory:stderr=
  | 2024/11/28 11:40:11.038518 DEBUG RESTY
  | ==============================================================================
  | ~~~ REQUEST ~~~
  | POST  /artifactory/api/system/usage  HTTP/1.1
  | HOST   : priv.jfrog.io
  | HEADERS:
  | \tAccept: */*
  | \tAuthorization: <REDACTED>
  | \tContent-Type: application/json
  | \tUser-Agent: jfrog/terraform-provider-artifactory/12.5.1
  | BODY   :
  | {
  |    "productId": "terraform-provider-artifactory/12.5.1",
  |    "features": [
  |       {
  |          "featureId": "Partner/ACC-007450"
  |       },
  |       {
  |          "featureId": "Resource/artifactory_remote_docker_repository/UPDATE"
  |       }
  |    ]
  | }
  |
  | ------------------------------------------------------------------------------
  | ~~~ RESPONSE ~~~
  | STATUS       : 200
  | PROTO        : HTTP/1.1
  | RECEIVED AT  : 2024-11-28T11:40:11.038489-04:00
  | TIME DURATION: 68.776083ms
  | HEADERS      :
  | \tConnection: keep-alive
  | \tContent-Length: 0
  | \tDate: Thu, 28 Nov 2024 15:40:11 GMT
  | \tStrict-Transport-Security: max-age=31536000; includeSubDomains
  | \tX-Artifactory-Id: eccbaac55cf86c6eafbb2f82e5782725ac7d

2024-11-28T11:40:11.038-0400 [WARN]  unexpected data:
  registry.terraform.io/jfrog/artifactory:stderr=
  | 6dab
  | \tX-Artifactory-Node-Id: priv-artifactory-primary-0
  | \tX-Jfrog-Version: Artifactory/7.101.2 710102900
  | \tX-Request-Id: 2f7217ce1d00e28c171a790c46765acc
  | BODY         :
  | ***** NO CONTENT *****
  | ==============================================================================

2024-11-28T11:40:11.706-0400 [WARN]  unexpected data:
  registry.terraform.io/jfrog/artifactory:stderr=
  | 2024/11/28 11:40:11.706415 DEBUG RESTY
  | ==============================================================================
  | ~~~ REQUEST ~~~
  | POST  /artifactory/api/repositories/aws-ecr-registry-delete-me  HTTP/1.1
  | HOST   : priv.jfrog.io
  | HEADERS:
  | \tAccept: */*
  | \tAuthorization: <REDACTED>
  | \tContent-Type: application/json
  | \tUser-Agent: jfrog/terraform-provider-artifactory/12.5.1
  | BODY   :
  | {
  |    "key": "aws-ecr-registry-delete-me",
  |    "projectKey": "",
  |    "environments": [],
  |    "rclass": "remote",
  |    "packageType": "docker",
  |    "url": "https://gallery.ecr.aws",
  |    "username": "",
  |    "proxy": "",
  |    "disableProxy": false,
  |    "description": "Amazon ECR Public Gallery test again",
  |    "notes": "",
  |    "includesPattern": "**/*",
  |    "excludesPattern": "",
  |    "repoLayoutRef": "simple-default",
  |    "remoteRepoLayoutRef": "",
  |    "hardFail": false,
  |    "offline": false,
  |    "blackedOut": false,
  |    "xrayIndex": false,
  |    "priorityResolution": false,
  |    "storeArtifactsLocally": true,
  |    "socketTimeoutMillis": 15000,
  |    "localAddress"

2024-11-28T11:40:11.706-0400 [WARN]  unexpected data:
  registry.terraform.io/jfrog/artifactory:stderr=
  | : "",
  |    "retrievalCachePeriodSecs": 7200,
  |    "missedRetrievalCachePeriodSecs": 1800,
  |    "metadataRetrievalTimeoutSecs": 60,
  |    "unusedArtifactsCleanupPeriodHours": 0,
  |    "assumedOfflinePeriodSecs": 300,
  |    "shareConfiguration": false,
  |    "synchronizeProperties": false,
  |    "blockMismatchingMimeTypes": true,
  |    "propertySets": [
  |       "artifactory"
  |    ],
  |    "allowAnyHostAuth": false,
  |    "enableCookieManagement": false,
  |    "bypassHeadRequests": false,
  |    "contentSynchronisation": {
  |       "enabled": false,
  |       "statistics": {
  |          "enabled": false
  |       },
  |       "properties": {
  |          "enabled": false
  |       },
  |       "source": {
  |          "originAbsenceDetection": false
  |       }
  |    },
  |    "mismatchingMimeTypesOverrideList": "",
  |    "listRemoteFolderItems": false,
  |    "cdnRedirect": false,
  |    "disableUrlNormalization": false,
  |    "archiveBrowsingEnabled": false,
  |    "curated": false,
  |    "externalDependenciesEnabled": false,
  |    "externalDependenciesPatterns": [
  |       "**"
  |    ],
  |    "enableTokenAuthentication": fals

2024-11-28T11:40:11.706-0400 [WARN]  unexpected data:
  registry.terraform.io/jfrog/artifactory:stderr=
  | e,
  |    "blockPushingSchema1": false,
  |    "dockerProjectId": ""
  | }
  |
  | ------------------------------------------------------------------------------
  | ~~~ RESPONSE ~~~
  | STATUS       : 400
  | PROTO        : HTTP/1.1
  | RECEIVED AT  : 2024-11-28T11:40:11.706326-04:00
  | TIME DURATION: 736.457625ms
  | HEADERS      :
  | \tConnection: keep-alive
  | \tContent-Type: application/json
  | \tDate: Thu, 28 Nov 2024 15:40:11 GMT
  | \tStrict-Transport-Security: max-age=31536000; includeSubDomains
  | \tX-Artifactory-Id: eccbaac55cf86c6eafbb2f82e5782725ac7d6dab
  | \tX-Artifactory-Node-Id: priv-artifactory-primary-0
  | \tX-Jfrog-Version: Artifactory/7.101.2 710102900
  | BODY         :
  | {
  |    "errors": [
  |       {
  |          "status": 400,
  |          "message": "HTTP response status 404:Failed to execute add project resource with error Could not find project ``"
  |       }
  |    ]
  | }
  | ==============================================================================

2024-11-28T11:40:11.707-0400 [ERROR] provider.terraform-provider-artifactory_v12.5.1: Response contains error diagnostic:
  diagnostic_summary=
  | {
  |   "errors" : [ {
  |     "status" : 400,
  |     "message" : "HTTP response status 404:Failed to execute add project resource with error Could not find project ``"
  |   } ]
  | }
   tf_provider_addr=jfrog/artifactory tf_rpc=ApplyResourceChange @module=sdk.proto diagnostic_detail="" tf_req_id=2c715812-0bf9-f4c1-029c-e64560d5813a tf_resource_type=artifactory_remote_docker_repository @caller=github.com/hashicorp/[email protected]/tfprotov6/internal/diag/diagnostics.go:58 diagnostic_severity=ERROR tf_proto_version=6.7 timestamp=2024-11-28T11:40:11.707-0400
2024-11-28T11:40:11.710-0400 [DEBUG] State storage *remote.State declined to persist a state snapshot
2024-11-28T11:40:11.710-0400 [ERROR] vertex "artifactory_remote_docker_repository.repository[0]" error: {
  "errors" : [ {
    "status" : 400,
    "message" : "HTTP response status 404:Failed to execute add project resource with error Could not find project ``"
  } ]
}
@Osazz Osazz added the bug Something isn't working label Nov 28, 2024
@Junkern
Copy link

Junkern commented Dec 2, 2024

We also encounter this issue.
For us it happens with two artifactory_remote_terraform_repository resources. We also have many other remote/virtuals repos (also docker) which are not affected.

We are running on terraform provider version 11.6.0 - to me it looks like this is not a problem of the provider, but a problem of Artifactory itself?

@alexhung
Copy link
Member

alexhung commented Dec 2, 2024

@Osazz @Junkern Thanks for the report. This issue is introduced by RTDEV-49236 in Artifactory v7.101.2. See release note.

The Artifactory engineering team is working on a fix/patch. I don't have a ETA or release version yet. Once I know, I'll pass it on here.

@alexhung alexhung added the blocked Blocked by dependent ticket label Dec 2, 2024
@alexhung alexhung pinned this issue Dec 2, 2024
@zamanh
Copy link

zamanh commented Dec 3, 2024

I am also seeing this issue on Artifactory version 7.77.5. Specifically when trying to use the platform_permission resource https://registry.terraform.io/providers/jfrog/platform/latest/docs/resources/permission. Using the same TF version and providers as the OP. Alongside the latest platform provider. In this case I am trying to create some groups, assign users to the groups and set permissions at the group level.

@zamanh
Copy link

zamanh commented Dec 3, 2024

See my debug log below:

Expand for more info
2024-12-03T16:27:06.605Z [INFO]  Starting apply for platform_group.my-group
2024-12-03T16:27:06.605Z [DEBUG] platform_group.my-group: applying the planned Create change
2024-12-03T16:27:06.701Z [WARN]  unexpected data:
  registry.terraform.io/jfrog/platform:stderr=
  | 2024/12/03 16:27:06.701466 DEBUG RESTY
  | ==============================================================================
  | ~~~ REQUEST ~~~
  | POST  /artifactory/api/system/usage  HTTP/1.1
  | HOST   : REDACTED
  | HEADERS:
  | \tAccept: */*
  | \tAuthorization: <REDACTED>
  | \tContent-Type: application/json
  | \tUser-Agent: jfrog/terraform-provider-platform/1.18.2
  | BODY   :
  | {
  |    "productId": "terraform-provider-platform/1.18.2",
  |    "features": [
  |       {
  |          "featureId": "Partner/ACC-007450"
  |       },
  |       {
  |          "featureId": "Resource/platform_group/CREATE"
  |       }
  |    ]
  | }
  |
  | ------------------------------------------------------------------------------
  | ~~~ RESPONSE ~~~
  | STATUS       : 200 OK
  | PROTO        : HTTP/2.0
  | RECEIVED AT  : 2024-12-03T16:27:06.701443432Z
  | TIME DURATION: 94.505076ms
  | HEADERS      :
  | \tContent-Length: 0
  | \tDate: Tue, 03 Dec 2024 16:26:58 GMT
  | \tX-Artifactory-Id: REDACT
  | \tX-Artifactory-Node-Id: REDACT
  | \tX-Jfrog-Version: Artifactory/7.77.5 77705900
  | BODY         :
  | **

2024-12-03T16:27:06.702Z [WARN]  unexpected data:
  registry.terraform.io/jfrog/platform:stderr=
  | *** NO CONTENT *****
  | ==============================================================================
  | 2024/12/03 16:27:06.701485 DEBUG RESTY
  | ==============================================================================
  | ~~~ REQUEST ~~~
  | POST  /artifactory/api/system/usage  HTTP/1.1
  | HOST   : REDACT
  | HEADERS:
  | \tAccept: */*
  | \tAuthorization: <REDACTED>
  | \tContent-Type: application/json
  | \tUser-Agent: jfrog/terraform-provider-platform/1.18.2
  | BODY   :
  | {
  |    "productId": "terraform-provider-platform/1.18.2",
  |    "features": [
  |       {
  |          "featureId": "Partner/ACC-007450"
  |       },
  |       {
  |          "featureId": "Terraform/1.9.8"
  |       }
  |    ]
  | }
  |
  | ------------------------------------------------------------------------------
  | ~~~ RESPONSE ~~~
  | STATUS       : 200 OK
  | PROTO        : HTTP/2.0
  | RECEIVED AT  : 2024-12-03T16:27:06.701462633Z
  | TIME DURATION: 100.749473ms
  | HEADERS      :
  | \tContent-Length: 0
  | \tDate: Tue, 03 Dec 2024 16:26:58 GMT
  | \tX-Artifactory-Id: 407ded88a8493ae067eb7307fb3cf7bd998b9370
  | \tX-Artifactory

2024-12-03T16:27:06.702Z [WARN]  unexpected data:
  registry.terraform.io/jfrog/platform:stderr=
  | -Node-Id: 
  | \tX-Jfrog-Version: Artifactory/7.77.5 77705900
  | BODY         :
  | ***** NO CONTENT *****
  | ==============================================================================
  | 2024/12/03 16:27:06.701511 DEBUG RESTY
  | ==============================================================================
  | ~~~ REQUEST ~~~
  | POST  /artifactory/api/system/usage  HTTP/1.1
  | HOST   : 
  | HEADERS:
  | \tAccept: */*
  | \tAuthorization: <REDACTED>
  | \tContent-Type: application/json
  | \tUser-Agent: jfrog/terraform-provider-platform/1.18.2
  | BODY   :
  | {
  |    "productId": "terraform-provider-platform/1.18.2",
  |    "features": [
  |       {
  |          "featureId": "Partner/ACC-007450"
  |       },
  |       {
  |          "featureId": "Terraform/1.9.8"
  |       }
  |    ]
  | }
  |
  | ------------------------------------------------------------------------------
  | ~~~ RESPONSE ~~~
  | STATUS       : 200 OK
  | PROTO        : HTTP/2.0
  | RECEIVED AT  : 2024-12-03T16:27:06.701501934Z
  | TIME DURATION: 100.762373ms
  | HEADERS      :
  | \tContent-Length: 0
  | \tDate: Tue, 03 Dec 2024 1

2024-12-03T16:27:06.702Z [WARN]  unexpected data:
  registry.terraform.io/jfrog/platform:stderr=
  | 6:26:58 GMT
  | \tX-Artifactory-Id: 407ded88a8493ae067eb7307fb3cf7bd998b9370
  | \tX-Artifactory-Node-Id: 0c75db37b657
  | \tX-Jfrog-Version: Artifactory/7.77.5 77705900
  | BODY         :
  | ***** NO CONTENT *****
  | ==============================================================================
  | 2024/12/03 16:27:06.701511 DEBUG RESTY
  | ==============================================================================
  | ~~~ REQUEST ~~~
  | POST  /access/api/v2/groups  HTTP/1.1
  | HEADERS:
  | \tAccept: */*
  | \tAuthorization: <REDACTED>
  | \tContent-Type: application/json
  | \tUser-Agent: jfrog/terraform-provider-platform/1.18.2
  | BODY   :
  | {
  |    "name": "my-group",
  |    "description": "My group",
  |    "external_id": "My Azure ID",
  |    "auto_join": true,
  |    "admin_privileges": false
  | }
  |
  | ------------------------------------------------------------------------------
  | ~~~ RESPONSE ~~~
  | STATUS       : 404 Not Found
  | PROTO        : HTTP/2.0
  | RECEIVED AT  : 2024-12-03T16:27:06.701489734Z
  | TIME DURATION: 94.61098ms
  | HEADERS      :
  | \tContent-Type: a

2024-12-03T16:27:06.702Z [WARN]  unexpected data:
  registry.terraform.io/jfrog/platform:stderr=
  | pplication/json
  | \tDate: Tue, 03 Dec 2024 16:26:58 GMT
  | \tX-Artifactory-Id: 407ded88a8493ae067eb7307fb3cf7bd998b9370
  | \tX-Artifactory-Node-Id: 0c75db37b657
  | \tX-Jfrog-Version: Artifactory/7.77.5 77705900
  | BODY         :
  | {
  |    "errors": [
  |       {
  |          "status": 404,
  |          "message": "Not Found"
  |       }
  |    ]
  | }
  | ==============================================================================

2024-12-03T16:27:06.702Z [DEBUG] State storage *remote.State declined to persist a state snapshot
2024-12-03T16:27:06.702Z [ERROR] vertex "platform_group.my-group" error: Unable to Create Resource
2024-12-03T16:27:06.701Z [ERROR] provider.terraform-provider-platform_v1.18.2: Response contains error diagnostic: tf_provider_addr=registry.terraform.io/jfrog/platform tf_resource_type=platform_group @module=sdk.proto diagnostic_severity=ERROR
  diagnostic_detail=
  | An unexpected error occurred while creating the resource update request. Please report this issue to the provider developers.
  |
  | Error: Not Found
   diagnostic_summary="Unable to Create Resource" tf_proto_version=6.7 tf_req_id=ed1fa277-3192-224b-62a6-e85d7d02fee7 tf_rpc=ApplyResourceChange @caller=github.com/hashicorp/[email protected]/tfprotov6/internal/diag/diagnostics.go:58 timestamp=2024-12-03T16:27:06.701Z
Sample code used to generate the above
resource "platform_group" "my-group" {
  name             = "my-group"
  description      = "My group"
  auto_join        = true
  admin_privileges = false
}

resource "artifactory_managed_user" "test-user" {
  name     = "test-user"
  password = "dcfsdcfsdcsdcsdZ!£"
  email    = "[email protected]"
  groups   = [platform_group.my-group.name]
}

resource "platform_permission" "my-permission" {
  name = "my-permission-name"

  artifact = {
    actions = {
      groups = [
        {
          name = platform_group.my-group.name
          permissions = ["READ", "WRITE"]
        }
      ]
    }

    targets = [
      {
        name = "test-repo"
        include_patterns = ["**"]
      }
    ]
  }
}

@alexhung
Copy link
Member

alexhung commented Dec 3, 2024

@zamanh Please create an issue in the Platform repo. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked Blocked by dependent ticket bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants