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

Existings azurerm_app_configuration_key broken after upgrade to 3.38.0 -> v3.46.0 #20849

Closed
1 task done
Socolin opened this issue Mar 8, 2023 · 4 comments · Fixed by #20082
Closed
1 task done

Existings azurerm_app_configuration_key broken after upgrade to 3.38.0 -> v3.46.0 #20849

Socolin opened this issue Mar 8, 2023 · 4 comments · Fixed by #20082

Comments

@Socolin
Copy link

Socolin commented Mar 8, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform Version

v1.3.7

AzureRM Provider Version

3.46.0

Affected Resource(s)/Data Source(s)

azurerm_app_configuration_key

Terraform Configuration Files

resource "azurerm_app_configuration_key" "SharedSentinel" {
  configuration_store_id = azurerm_app_configuration.config.id

  key          = "SharedSentinel"
  value        = "4"
  content_type = ""
}

Debug Output/Panic Output

╷
│ Error: parsing "/subscriptions/474fd901-117f-4540-9459-d79c2c7e2591/resourceGroups/some-rg/providers/Microsoft.AppConfiguration/configurationStores/some-az-config/AppConfigurationKey/SharedSentinel/Label/\x00": unexpected segment "AppConfigurationKey/SharedSentinel/Label/\x00" present at the end of the URI (input "/subscriptions/474fd901-117f-4540-9459-d79c2c7e2591/resourceGroups/some-rg/providers/Microsoft.AppConfiguration/configurationStores/some-az-config/AppConfigurationKey/SharedSentinel/Label/\x00")
│
│   with azurerm_app_configuration_key.SharedSentinel,
│   on appconfig.tf line 12, in resource "azurerm_app_configuration_key" "SharedSentinel":
│   12: resource "azurerm_app_configuration_key" "SharedSentinel" {
│
│ parsing "/subscriptions/474fd901-117f-4540-9459-d79c2c7e2591/resourceGroups/some-rg/providers/Microsoft.AppConfiguration/configurationStores/some-az-config/AppConfigurationKey/SharedSentinel/Label/\x00":
│ unexpected segment "AppConfigurationKey/SharedSentinel/Label/\x00" present at the end of the URI (input
│ "/subscriptions/474fd901-117f-4540-9459-d79c2c7e2591/resourceGroups/some-rg/providers/Microsoft.AppConfiguration/configurationStores/some-az-config/AppConfigurationKey/SharedSentinel/Label/\x00")
╵

Expected Behaviour

Should not display an error

Actual Behaviour

No response

Steps to Reproduce

Previously existing state with this resources

Important Factoids

was working in v3.38.0

References

No response

@Socolin Socolin added the bug label Mar 8, 2023
@github-actions github-actions bot removed the bug label Mar 8, 2023
@teowa
Copy link
Contributor

teowa commented Mar 13, 2023

Hi @Socolin , thanks for submitting this issue.
There are something wrong with the azurerm_app_configuration_key resource ID format \x00 segment. I cannot repro the error with below config upgrading provider from 3.38.0 to 3.46.0. The error may source from the empty label property and code modifications in recent provder versions. As a possible workaround, could you please try with terraform plan -refresh=false or terraform apply -refresh=false, although this may incur the force replacement, but after that the resource should work well.

tf config
terraform {
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "=3.38.0"
    }
  }
}

provider "azurerm" {
  features {}
}

resource "azurerm_resource_group" "example" {
  name     = "example-resources"
  location = "West Europe"
}

resource "azurerm_app_configuration" "appconf" {
  name                = "ttestappConf1"
  resource_group_name = azurerm_resource_group.example.name
  location            = azurerm_resource_group.example.location
}

resource "azurerm_app_configuration_key" "test" {
  configuration_store_id = azurerm_app_configuration.appconf.id
  key          = "SharedSentinel"
  value        = "4"
  content_type = ""
}

@Socolin
Copy link
Author

Socolin commented Mar 13, 2023

with -refresh=false it does nothing, not changes detected, and as soon I do it without it, I get the error.

The \00 was added there 6b3cd2c

See the comment at the time, this part of the code seem sto have been removed

// Golang's URL parser will translate %00 to \000 (NUL). This will only happen if we're dealing with an empty

This is clearly a regression.

@teowa
Copy link
Contributor

teowa commented Mar 21, 2023

Found the error upgrading API version from earlier version like 3.30.0 to 3.46.0, the resource ID will become, I have submitted PR #20082 to fix this.

azurerm_app_configuration_key.test: Refreshing state... [id=/subscriptions/xxx/resourceGroups/ex-resources/providers/Microsoft.AppConfiguration/configurationStores/wttsapp1Conf1/AppConfigurationKey/appConfKey1/Label//AppConfigurationKey/appConfKey1/Label/]
╷
│ Error: while parsing resource ID: while parsing resource ID: the number of path segments is not divisible by 2 in "subscriptions/xxx/resourceGroups/ex-resources/providers/Microsoft.AppConfiguration/configurationStores/wttsapp1Conf1/AppConfigurationKey/appConfKey1%2FLabel%2F%00%2FAppConfigurationKey%2FappConfKey1/Label"
│
│   with azurerm_app_configuration_key.test,
│   on main.tf line 31, in resource "azurerm_app_configuration_key" "test":
│   31: resource "azurerm_app_configuration_key" "test" {
│
│ while parsing resource ID: while parsing resource ID: the number of path segments is not divisible by 2 in
│ "subscriptions/xxx/resourceGroups/ex-resources/providers/Microsoft.AppConfiguration/configurationStores/wttsapp1Conf1/AppConfigurationKey/appConfKey1%2FLabel%2F%00%2FAppConfigurationKey%2FappConfKey1/Label"
tf config
terraform {
  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "=3.30.0"
    }
  }
}

provider "azurerm" {
  features {}
}

resource "azurerm_resource_group" "example" {
  name     = "example-resources"
  location = "West Europe"
}

resource "azurerm_app_configuration" "appconf" {
  name                = "ttestappConf1"
  resource_group_name = azurerm_resource_group.example.name
  location            = azurerm_resource_group.example.location
}

resource "azurerm_app_configuration_key" "test" {
  configuration_store_id = azurerm_app_configuration.appconf.id
  key          = "SharedSentinel"
  value        = "4"
  content_type = ""
}

teowa added a commit to teowa/terraform-provider-azurerm that referenced this issue Mar 21, 2023
@github-actions
Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
4 participants