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

postgresql_grant: Error: could not execute revoke query: pq: zero-length delimited identifier at or near """" #451

Open
loganmzz opened this issue Jul 2, 2024 · 1 comment

Comments

@loganmzz
Copy link

loganmzz commented Jul 2, 2024

Terraform Version

Terraform v1.5.7

Affected Resource(s)

  • postgresql_grant

Terraform Configuration Files

resource "postgresql_grant" "public_database_connect" {
  database    = "test_db"
  role        = "test_role"
  schema      = "public"
  object_type = "database"
  privileges  = ["CONNECT"]
}

Debug Output

2024-07-02T10:53:59.095+0200 [DEBUG] provider: plugin started: path=.terraform/providers/registry.terraform.io/cyrilgdn/postgresql/1.22.0/linux_amd64/terraform-provider-postgresql_v1.22.0 pid=196227
2024-07-02T10:53:59.095+0200 [DEBUG] provider: waiting for RPC address: path=.terraform/providers/registry.terraform.io/cyrilgdn/postgresql/1.22.0/linux_amd64/terraform-provider-postgresql_v1.22.0
2024-07-02T10:53:59.105+0200 [INFO]  provider.terraform-provider-postgresql_v1.22.0: configuring server automatic mTLS: timestamp=2024-07-02T10:53:59.105+0200
2024-07-02T10:53:59.123+0200 [DEBUG] provider: using plugin: version=5
2024-07-02T10:53:59.123+0200 [DEBUG] provider.terraform-provider-postgresql_v1.22.0: plugin address: network=unix address=/tmp/plugin3940814070 timestamp=2024-07-02T10:53:59.123+0200
2024-07-02T10:53:59.138+0200 [WARN]  ValidateProviderConfig from "provider[\"registry.terraform.io/cyrilgdn/postgresql\"]" changed the config value, but that value is unused
2024-07-02T10:53:59.142+0200 [WARN]  Provider "registry.terraform.io/cyrilgdn/postgresql" produced an invalid plan for postgresql_grant.public_database_connect, 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:
      - .with_grant_option: planned value cty.False for a non-computed attribute
2024-07-02T10:53:59.142+0200 [INFO]  Starting apply for postgresql_grant.public_database_connect
2024-07-02T10:53:59.143+0200 [DEBUG] postgresql_grant.public_database_connect: applying the planned Create change
2024-07-02T10:54:00.469+0200 [ERROR] provider.terraform-provider-postgresql_v1.22.0: Response contains error diagnostic: tf_rpc=ApplyResourceChange @caller=github.com/hashicorp/[email protected]/tfprotov5/internal/diag/diagnostics.go:55 diagnostic_severity=ERROR diagnostic_summary="could not execute revoke query: pq: zero-length delimited identifier at or near """"" tf_req_id=203472e2-3fc8-96b5-5e6c-46c4de71e634 tf_provider_addr=provider tf_resource_type=postgresql_grant @module=sdk.proto diagnostic_detail= tf_proto_version=5.3 timestamp=2024-07-02T10:54:00.469+0200
2024-07-02T10:54:00.470+0200 [DEBUG] State storage *remote.State declined to persist a state snapshot
2024-07-02T10:54:00.470+0200 [ERROR] vertex "postgresql_grant.public_database_connect" error: could not execute revoke query: pq: zero-length delimited identifier at or near """"

Panic Output

N/A

Expected Behavior

Success

Actual Behavior

Failing by executing unknown invalid SQL request:

│ Error: could not execute revoke query: pq: zero-length delimited identifier at or near """"
│ 
│   with postgresql_grant.public_database_connect,
│   on pgsql.tf line 181, in resource "postgresql_grant" "public_database_connect":
│  181: resource "postgresql_grant" "public_database_connect" {

Steps to Reproduce

  1. terraform apply

Important Factoids

Database may have been partially setup by another process/Terraform script. But role is new.

References

N/A

@loganmzz
Copy link
Author

loganmzz commented Jul 2, 2024

For unknown reason, database was empty or null (get from a Terraform data), but Provider should check and complain about missing or invalid database attribute

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant