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

Error: Unexpected ID format (""), expected numerical ID. strconv.ParseInt: parsing "": invalid syntax #608

Closed
ghost opened this issue Nov 16, 2020 · 4 comments · Fixed by #1074
Labels
r/team_membership Type: Bug Something isn't working as documented

Comments

@ghost
Copy link

ghost commented Nov 16, 2020

This issue was originally opened by @pbharambe as hashicorp/terraform#26923. It was migrated here as a result of the provider split. The original body of the issue is below.


Getting "strconv.ParseInt: parsing" error while destroying exiting team membership in terraform apply.

Terraform Version

Terraform v0.12.24

Terraform Configuration Files

repositories.tf

variable "github_token" {}

provider "github" {
  version = "~> 2.2.1"

  base_url     = "https://api.github.com/"
  organization = "pankajlab"
  token        = "${var.github_token}"
}

/***********************************************************************************************************************
 * TEAMS
 */
resource "github_team" "app-developers" {
  name        = "app-developers"
  description = "All app Developers."
  privacy     = "closed"
}

resource "github_team" "admin" {
  name    = "admin"
  privacy = "closed"
}

resource "github_team_membership" "pbharambe" {
  team_id  = "${github_team.admin.id}"
  username = "pbharambe"
  role     = "maintainer"
}

locals {
  app_team_ids = [
    "${github_team.app-developers.id}"
  ]
}

/***********************************************************************************************************************
 * REPOSITORIES
 */

module "cf-environments" {
  source = "./modules/github"

  repository_name = "cf-environments"
  description     = "Configurations defining Cloud Foundry environments along with the tools for managing them."

  branches_to_protect = ["master"]

  admin_team_id = "${github_team.admin.id}"
  team_ids      = "${local.app_team_ids}"
}

module "database-management" {
  source = "./modules/github"

  repository_name = "database-management"

  branches_to_protect = ["master"]

  admin_team_id = "${github_team.admin.id}"
  team_ids      = "${local.app_team_ids}"
}
------------------------------------------------------------------------------------
main.tf

variable "repository_name" {}

variable "auto_init" {
  default = true
}

variable "description" {
  default = ""
}

variable "private" {
  default = false
}

variable "has_downloads" {
  default = true
}

variable "has_issues" {
  default = true
}

variable "has_wiki" {
  default = true
}

variable "allow_merge_commit" {
  default = false
}

variable "allow_squash_merge" {
  default = true
}

variable "allow_rebase_merge" {
  default = false
}

variable "branches_to_protect" {
  type    = "list"
  default = ["master"]
}

variable "admin_team_id" {
  default = ""
}

variable "team_ids" {
  type    = "list"
  default = []
}

variable "enforce_admins" {
  default = true
}

resource "github_repository" "main" {
  name        = "${var.repository_name}"
  description = "${var.description}"

  private = "${var.private}"

  has_downloads = "${var.has_downloads}"
  has_issues    = "${var.has_issues}"
  has_wiki      = "${var.has_wiki}"

  allow_merge_commit = "${var.allow_merge_commit}"
  allow_squash_merge = "${var.allow_squash_merge}"
  allow_rebase_merge = "${var.allow_rebase_merge}"

  auto_init = "${var.auto_init}"

  lifecycle {
    prevent_destroy = true
  }
}

resource "github_team_repository" "admin" {
  team_id    = "${var.admin_team_id}"
  repository = "${github_repository.main.name}"
  permission = "admin"
}

resource "github_team_repository" "main" {
  count = "${length(var.team_ids)}"

  team_id    = "${var.team_ids[count.index]}"
  repository = "${github_repository.main.name}"
  permission = "push"
}

resource "github_branch_protection" "main" {
  count = "${length(var.branches_to_protect)}"

  repository = "${github_repository.main.name}"
  branch     = "${var.branches_to_protect[count.index]}"

  required_pull_request_reviews {
    dismiss_stale_reviews = true
    dismissal_teams       = ["${var.admin_team_id}"]
  }

  enforce_admins = false
}


Expected Behavior

The membership should have removed first and then the user from the organization.

Actual Behavior

github_team_membership.pbharambe: Destroying... [id=4275642:pbharambe]

Error: Unexpected ID format (""), expected numerical ID. strconv.ParseInt: parsing "": invalid syntax

Steps to Reproduce

  1. terraform init
  2. terraform plan
  3. terraform apply
@spuder
Copy link

spuder commented Nov 24, 2021

I'm seeing almost exactly the same thing. We lost our state file, when attemping to re-import resources we get the following error

resource "gitlab_branch_protection" "ultraman-int" {
  project            = 1234
  branch             = "int"
  push_access_level  = "maintainer"
  merge_access_level = "maintainer"
}
terraform import gitlab_branch_protection_ultraman-int ultraman-int
gitlab_branch_protection.ultraman-int: Importing from ID "ultraman-int"...
gitlab_branch_protection.ultraman-int: Import prepared!
  Prepared gitlab_branch_protection for import
gitlab_branch_protection.ultraman-int: Refreshing state... [id=ultraman-int]
╷
│ Error: Unexpected ID format ("ultraman-int"). Expected project:key
│ 
│ 
╵

@spuder
Copy link

spuder commented Nov 24, 2021

It appears that gitlab_branch_protection does not support import.

Our workaround was to manually delete all gitlab branch protections in the gitlab gui, then let terraform recreate them.

@m-adawi
Copy link

m-adawi commented Feb 8, 2022

I got the same error trying to import a github_team_members resource

@SpencerMalone
Copy link

This is hitting us as well! I would classify it as a large blocker for utilizing this provider.

brandon-at-wrk pushed a commit to brandon-at-wrk/terraform-provider-github that referenced this issue Feb 23, 2022
…s` objects

When importing a `github_team_member`, the import command passes in the data as the
"Id", not the "team_id", causing the import step to fail when parsing an empty string
as a number. Should fix integrations#608, as I hit the same error.
brandon-at-wrk pushed a commit to brandon-at-wrk/terraform-provider-github that referenced this issue Feb 23, 2022
…s` objects

When importing a `github_team_member`, the import command passes in team ID as the
"Id", not the "team_id" captured in the state for existing resources, and this empty string is
causing the import step to fail when parsing as a number. Should fix integrations#608, as I hit the same error.
kfcampbell pushed a commit that referenced this issue Mar 11, 2022
…s` objects (#1074)

When importing a `github_team_member`, the import command passes in team ID as the
"Id", not the "team_id" captured in the state for existing resources, and this empty string is
causing the import step to fail when parsing as a number. Should fix #608, as I hit the same error.
kfcampbell pushed a commit to kfcampbell/terraform-provider-github that referenced this issue Jul 26, 2022
…s` objects (integrations#1074)

When importing a `github_team_member`, the import command passes in team ID as the
"Id", not the "team_id" captured in the state for existing resources, and this empty string is
causing the import step to fail when parsing as a number. Should fix integrations#608, as I hit the same error.
kazaker pushed a commit to auto1-oss/terraform-provider-github that referenced this issue Dec 28, 2022
…s` objects (integrations#1074)

When importing a `github_team_member`, the import command passes in team ID as the
"Id", not the "team_id" captured in the state for existing resources, and this empty string is
causing the import step to fail when parsing as a number. Should fix integrations#608, as I hit the same error.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
r/team_membership Type: Bug Something isn't working as documented
Projects
None yet
4 participants