Skip to content

[BUG]: Always got 422 error when using github_user_gpg_key #2743

@czchen

Description

@czchen

Expected Behavior

The resource github_user_gpg_key shall be able to manage gpg key without problem.

Actual Behavior

The following 422 Validation Failed error message always appear when applying. Despite the error, the GPG key is set successful.

github_user_ssh_key.czchen: Creating...
github_user_gpg_key.czchen: Creating...
github_user_ssh_key.czchen: Creation complete after 4s [id=130245418]
╷
│ Error: POST https://api.github.com/user/gpg_keys: 422 Validation Failed [{Resource:GpgKey Field: Code:custom Message:The key was not added because one or more subkeys already exist: E965B338BCC5F139, F10B37545CBC1B32}]
│
│   with github_user_gpg_key.czchen,
│   on main.tf line 22, in resource "github_user_gpg_key" "czchen":
│   22: resource "github_user_gpg_key" "czchen" {

Terraform Version

OpenTofu v1.10.2 on linux amd64
Provider version 6.6.0

Affected Resource(s)

  • github_user_gpg_key

Terraform Configuration Files

resource "github_user_gpg_key" "czchen" {
  armored_public_key = var.gpg_key_value
}

Steps to Reproduce

$ tofu apply

Debug Output

github_user_gpg_key.czchen: Creating...
2025-08-29T00:18:21.954+0800 [INFO]  Starting apply for github_user_gpg_key.czchen
2025-08-29T00:18:21.955+0800 [DEBUG] github_user_gpg_key.czchen: applying the planned Create change
2025-08-29T00:18:22.956+0800 [ERROR] provider.terraform-provider-github_v6.6.0: Response contains error diagnostic: tf_proto_version=5.6 tf_rpc=ApplyResourceChange diagnostic_detail="" diagnostic_severity=ERROR diagnostic_summary="POST https://api.github.com/user/gpg_keys: 422 Validation Failed [{Resource:GpgKey Field: Code:custom Message:The key was not added because one or more subkeys already exist: E965B338BCC5F139, F10B37545CBC1B32}]" tf_provider_addr=provider tf_req_id=9ada5f3b-f4e5-f81f-1f7d-f9ea1bbdff8a tf_resource_type=github_user_gpg_key @caller=github.com/hashicorp/terraform-plugin-go@v0.23.0/tfprotov5/internal/diag/diagnostics.go:58 @module=sdk.proto timestamp="2025-08-29T00:18:22.956+0800"
2025-08-29T00:18:22.957+0800 [DEBUG] State storage *remote.State declined to persist a state snapshot
2025-08-29T00:18:22.957+0800 [ERROR] vertex "github_user_gpg_key.czchen" error: POST https://api.github.com/user/gpg_keys: 422 Validation Failed [{Resource:GpgKey Field: Code:custom Message:The key was not added because one or more subkeys already exist: E965B338BCC5F139, F10B37545CBC1B32}]
2025-08-29T00:18:22.957+0800 [DEBUG] states/remote: state read serial is: 95; serial is: 95
2025-08-29T00:18:22.957+0800 [DEBUG] states/remote: state read lineage is: 2fcccf7a-f8fe-b395-b19f-6f51a611dfe3; lineage is: 2fcccf7a-f8fe-b395-b19f-6f51a611dfe3

Panic Output

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: TriageThis is being looked at and prioritizedType: BugSomething isn't working as documented

    Type

    No type

    Projects

    Status

    🆕 Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions