Skip to content

validate filter length doesn't exceed 256 bytes in subscription #19131

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

Conversation

modular-magician
Copy link
Collaborator

This PR validates that the filter length doesn't exceed 256 bytes in a PubSub subscription, on TF it should fail when planning

Release Note Template for Downstream PRs (will be copied)

pusbub: added validation to `filter` field for `google_pubsub_subscription`

Derived from GoogleCloudPlatform/magic-modules#11421

…icorp#11421)

[upstream:ff502095f0d2b0e2290b9036099ad7218854c4ea]

Signed-off-by: Modular Magician <[email protected]>
@modular-magician modular-magician merged commit 2be944a into hashicorp:main Aug 14, 2024
2 checks passed
@philvmx1
Copy link

philvmx1 commented Aug 27, 2024

@modular-magician this change caused our builds to fail since we have 0-length subscriptions (empty string).

Please reference the API documentation for "filter" https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.subscriptions/create

It implicitly says that empty strings are allowed.

@ndopj
Copy link

ndopj commented Sep 2, 2024

@modular-magician this is breaking change which was not released under new Major version. The API allows filters to contain new line characters. This is useful when Terraform users use Heredoc strings for attributes expecting string type.

Example for PubSub filter:

resource "google_pubsub_subscription" "events" {
  name   = "events"
  topic  = google_pubsub_topic.events.name
  filter = <<-EOT
  (attributes.platform = "web" AND attributes.category = "shopping_cart")
  OR (attributes.platform = "app")
  EOT
}

The above filter used to work before the change introduced in this MR. Introduced regex, ^.{1,256}$, used for validation of the filter attribute does not allow new lines to be present in the provided string value.

Copy link

github-actions bot commented Oct 3, 2024

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 3, 2024
@modular-magician modular-magician deleted the downstream-pr-ff502095f0d2b0e2290b9036099ad7218854c4ea branch November 17, 2024 02:53
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants