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

Adding user to environment returns: "panic: runtime error: index out of range [0] with length 0" #617

Open
eduardodfmex opened this issue Mar 5, 2025 · 2 comments
Labels
bug Something isn't working

Comments

@eduardodfmex
Copy link
Contributor

Adding user to environment returns: "panic: runtime error"

Adding users by their AAD ID returns "panic: runtime error: index out of range [0] with length 0".
This errors occurs when there is no licenses available on the tenant to add the user.

Sample Terraform Code

If applicable, add terraform code to help explain your problem.

terraform {
  required_providers {
    powerplatform = {
      source = "microsoft/power-platform"
    }
  }
}

provider "powerplatform" {
  use_cli = true
}

resource "powerplatform_environment" "development" {
  display_name     = "example_environment"
  description      = "example environment description"
  location         = "europe"
  azure_region     = "northeurope"
  environment_type = "Sandbox"
  cadence          = "Moderate"
  dataverse = {
    language_code     = "1033"
    currency_code     = "USD"
    security_group_id = "00000000-0000-0000-0000-000000000000"
  }
}

variable "pp_environment_users" {
  description = "Entra tenant users that will be added to the environment taking entra user object_id"
  type        = map(string)
  value       = {
    "user1" = "user1_object_id"
    "user2" = "user2_object_id"
  }
}

#Add users to the Power Platform environment
resource "powerplatform_user" "pp_add_users" {
  for_each       = var.pp_environment_users
  environment_id = powerplatform_environment.development.id
  security_roles =  "e0d2794e-82f3-e811-a951-000d3a1bcf17", // bot author
  aad_id         = each.value
  disable_delete = false
  depends_on     = [time_sleep.wait_pp_environment]
}

Expected behavior

The error should tell the user that there is not licenses available to add the users or suggest to review if there are licenses available to add users.

Define the correct error to show should we change the current error: "panic: runtime error: index out of range [0] with length 0"

System Information

  • Provider Version: 3.3.0
  • OS & Version: Linux GitHub Runner

Additional context

Error:

##[debug] powerplatform_user.pp_add_users["user1"]: Still creating... [7m50s elapsed]
##[debug]
##[debug]Set output stderr = ╷
##[debug]│ Error: Plugin did not respond
##[debug]│
##[debug]│ The plugin encountered an error, and failed to respond to the
##[debug]│ plugin6.(*GRPCProvider).ApplyResourceChange call. The plugin logs may
##[debug]│ contain more details.
##[debug]╵
##[debug]╷
##[debug]│ Error: Plugin did not respond
##[debug]│
##[debug]│ The plugin encountered an error, and failed to respond to the
##[debug]│ plugin6.(*GRPCProvider).ApplyResourceChange call. The plugin logs may
##[debug]│ contain more details.
##[debug]╵
##[debug]╷
##[debug]│ Error: Plugin did not respond
##[debug]│
##[debug]│ The plugin encountered an error, and failed to respond to the
##[debug]│ plugin6.(*GRPCProvider).ApplyResourceChange call. The plugin logs may
##[debug]│ contain more details.
##[debug]╵
##[debug]╷
##[debug]│ Error: Plugin did not respond
##[debug]│
##[debug]│ The plugin encountered an error, and failed to respond to the
##[debug]│ plugin6.(*GRPCProvider).ApplyResourceChange call. The plugin logs may
##[debug]│ contain more details.
##[debug]╵
##[debug]╷
##[debug]│ Error: Plugin did not respond
##[debug]│
##[debug]│ The plugin encountered an error, and failed to respond to the
##[debug]│ plugin6.(*GRPCProvider).ApplyResourceChange call. The plugin logs may
##[debug]│ contain more details.
##[debug]╵
##[debug]╷
##[debug]│ Error: Plugin did not respond
##[debug]│
##[debug]│ The plugin encountered an error, and failed to respond to the
##[debug]│ plugin6.(*GRPCProvider).ApplyResourceChange call. The plugin logs may
##[debug]│ contain more details.
##[debug]╵
##[debug]
##[debug]Stack trace from the terraform-provider-power-platform_v3.3.0 plugin:
##[debug]
##[debug]panic: runtime error: index out of range [0] with length 0
##[debug]

Contribution

Do you plan to raise a PR to address this issue? YES.

@mattdot
Copy link
Member

mattdot commented Mar 6, 2025

is this a duplicate of #615 ?

@mawasile mawasile added the bug Something isn't working label Mar 6, 2025
@mawasile
Copy link
Contributor

mawasile commented Mar 6, 2025

is this a duplicate of #615 ?

yes

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

No branches or pull requests

3 participants