-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Add back requireds on stripquery #3443
Add back requireds on stripquery #3443
Conversation
Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are. Diff report:Terraform GA: Diff ( 4 files changed, 54 insertions(+), 60 deletions(-)) |
products/compute/api.yaml
Outdated
@@ -9452,11 +9452,11 @@ objects: | |||
- :TEMPORARY_REDIRECT | |||
- !ruby/object:Api::Type::Boolean | |||
name: 'stripQuery' | |||
default_value: false | |||
required: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should be 8 occurrences of stripQuery
in total:
pathMatchers.routeRules.urlRedirect.stripQuery
pathMatchers.pathRules.urlRedirect.stripQuery
pathMatchers.pathRules.defaultUrlRedirect.stripQuery
defaultUrlRedirect.stripQuery
And these for both for RegionUrlMap
and UrlMap
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are, but two of them were not marked as required
before. Marking them as required would be a breaking change that can't happen on a minor version
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. But then it should be noted somewhere, that these two blocks where the non-required stripQuery
properties appear exhibit the "empty block" problem that @danawillow pointed out.
375fb90
to
bcc53f2
Compare
Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are. Diff report:Terraform GA: Diff ( 4 files changed, 54 insertions(+), 60 deletions(-)) |
products/compute/api.yaml
Outdated
description: | | ||
If set to true, any accompanying query portion of the original URL is removed | ||
prior to redirecting the request. If set to false, the query portion of the | ||
original URL is retained. | ||
original URL is retained. The default value is false. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is required, it can't have a default
(here and elsewhere)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was going for saying the default so that people who don't want to specify this field but are required to have an idea of what the default normally is. But can remove
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have a strong opinion, but my guess is it would be more confusing to specify it. @ctavan, what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just played a bit with the API explorer at https://cloud.google.com/compute/docs/reference/rest/v1/urlMaps/insert
The API does not accept empty defaultUrlRedirect
objects, I assume the same is true for the urlRedirect
blocks although I didn't double check.
If I try to insert a new urlMap with these contents:
{
"name": "empty-url-map",
"defaultUrlRedirect": {}
}
I get an error:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "invalid",
"message": "Invalid value for field 'resource.defaultUrlRedirect': ''. No fields set for UrlRedirect"
}
],
"code": 400,
"message": "Invalid value for field 'resource.defaultUrlRedirect': ''. No fields set for UrlRedirect"
}
}
As soon as I set any field the insert works, e.g.:
{
"name": "empty-url-map",
"defaultUrlRedirect": {
"hostRedirect": "example.com"
}
}
I believe instead of making an arbitrary field mandatory I suggest that the correct way of handling this would be to specify
at_least_one_of:
- host_redirect
- path_redirect
- prefix_redirect
- redirect_response_code
- https_redirect
- strip_query
for all urlRedirect
/defaultUrlRedirect
blocks.
This should also be backwards-compatible for people who did specify strip_query
and it should also be "forward compatible" with those blocks that currently don't specify mandatory stripQuery fields because empty blocks are not accepted by the compute API anyways.
WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that sounds reasonable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, unfortunately because these fields are nested within lists we cannot enforce at_least_one_of
on them at this point.
We would definitely like to be able to enforce at_least_one_of
on nested objects within lists, but the current implementation does not support this
products/compute/api.yaml
Outdated
@@ -9871,11 +9871,11 @@ objects: | |||
- :TEMPORARY_REDIRECT | |||
- !ruby/object:Api::Type::Boolean | |||
name: 'stripQuery' | |||
default_value: false | |||
required: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Idea: does it make sense to do these as overrides in terraform.yaml instead? I don't think inspec/ansible have the same constraints around non-empty blocks, and so putting it there would make it easier to call out why we're doing this (we could group them all together more easily)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense. Do you think it is a good idea to explicitly say in the description "This is only required to ensure we do not allow an empty block in a terraform config"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure!
Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are. Diff report:Terraform GA: Diff ( 4 files changed, 74 insertions(+), 62 deletions(-)) |
180880f
to
8cb10e7
Compare
Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are. Diff report:Terraform GA: Diff ( 4 files changed, 74 insertions(+), 62 deletions(-)) |
8cb10e7
to
ed03897
Compare
Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are. Diff report:Terraform GA: Diff ( 4 files changed, 67 insertions(+), 61 deletions(-)) |
Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are. Diff report:Terraform GA: Diff ( 4 files changed, 66 insertions(+), 60 deletions(-)) |
@@ -14437,11 +14434,10 @@ objects: | |||
- :TEMPORARY_REDIRECT | |||
- !ruby/object:Api::Type::Boolean | |||
name: 'stripQuery' | |||
default_value: false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add these back so that ansible still has them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately not?
If we have a default value specified in api.yaml we cannot override it with a nil
value that I know of
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, but I can add them to ansible.yaml
Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are. Diff report:Terraform GA: Diff ( 4 files changed, 66 insertions(+), 60 deletions(-)) |
* Add back requireds on stripquery * Move required to terraform.yaml, add description on empty blocks' * Fixed to preserve backwards compatibility * Remove last default in description * Default back to false in ansible urlmaps
Reverts changes from #3378 to prevent empty blocks from being valid.
Adds required to the same field that was added in a duplicate object in #3379
This should be cherry-picked into 3.20.0
Release Note Template for Downstream PRs (will be copied)