Skip to content

Plan allows invalid labels #22246

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

Open
wyardley opened this issue Apr 4, 2025 · 3 comments
Open

Plan allows invalid labels #22246

wyardley opened this issue Apr 4, 2025 · 3 comments

Comments

@wyardley
Copy link

wyardley commented Apr 4, 2025

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.
  • If an issue is assigned to a user, that user is claiming responsibility for the issue.
  • Customers working with a Google Technical Account Manager or Customer Engineer can ask them to reach out internally to expedite investigation and resolution of this issue.

Terraform Version & Provider Version(s)

Terraform v1.11.3
on darwin_arm64

  • provider registry.terraform.io/hashicorp/google v6.28.0

Affected Resource(s)

google_*

Terraform Configuration

resource "google_pubsub_topic" "foo" {
  name = "foo"
  labels = {
    Team = "Foobar"
  }
}

Debug Output

No response

Expected Behavior

Plan should fail if the labels aren't valid

Actual Behavior

Plan / validate succeeds, then apply fails with

Error: Error creating Topic: googleapi: Error 400: You have passed an invalid argument to the service (argument=Invalid labels: Invalid field "labels"; key "Team" does not conform to regular expression "[\p{Ll}\p{Lo}][\p{Ll}\p{Lo}\p{N}_-]{0,62}"; first character "T" is not a non-uppercased letter (Unicode character class Ll or Lo)).

From spot-checking other resources, it seems like this is true with other services as well?

I recognize this may just be something that TPG can't validate before apply-time, but this seems like a common enough use case that, at least if it's consistent across resources, and there are no plans to allow upper-case characters in labels in the future, might be worth considering some provider level validation on?

Steps to reproduce

  1. terraform apply

Important Factoids

No response

References

terraform-linters/tflint-ruleset-google#413

@wyardley wyardley added the bug label Apr 4, 2025
@ggtisc ggtisc self-assigned this Apr 7, 2025
@ggtisc
Copy link
Collaborator

ggtisc commented Apr 7, 2025

Hi @wyardley I'm forwarding this as a possible enhancement for future releases

@ggtisc ggtisc removed their assignment Apr 7, 2025
@rileykarson rileykarson added this to the Backlog milestone Apr 14, 2025
@rileykarson
Copy link
Collaborator

@zli82016 labels had differentish formatting rules across services, right? That would make it difficult to write global validation.

@zli82016
Copy link
Collaborator

Most services should follow the unified formatting rules for labels (user labels and system labels). I am not sure if all of the services follow the rules.

User labels and system labels have different formatting rules. But they are not distinguished and all put into labels field.

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

No branches or pull requests

4 participants