Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Is there ever a scenario where we want to accept empty strings? If so, then we'd want the type to be a pointer reference so we can distinguish between a field not set vs a field that was explicitly set to an empty string.
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.
hmm, thanks for asking that. Let me test a bit more and will follow up.
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.
@Integralist Confirmed that we don't need to accept empty strings for
CreateGzipInput
struct. Ifcontent_types
andextensions
are not specified in a POST request, the default values are assigned automatically by the API backend.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.
Apologies in the slow reply.
The scenario I was curious about was more about does it make sense for
content_types
andextensions
to be set to an empty value. For example, if I use the gzip CREATE api endpoint directly (e.g. not using go-fastly) and I pass:Would the API still create a default for
content_types
or would it attempt tocontent_types
to an empty value? And would that be something we expect users to do?In the above example I'm trying to say I only care about gzipping files with the extensions 'html', 'css' and 'js' and I don't really care about gzipping responses that have a certain content_type.
But I guess it doesn't really matter if the API has provided its own defaults for
content_types
because if all I care about is what's inextensions
then that should be sufficient.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.
@Integralist I believe I sent a link in DM that refers to our internal PR.
I mentioned this in that PR, but we also had a bug in our API backend that we fail to set our default value if an empty value is sent for those parameters. This is going to be fixed very soon once that PR is deployed.
That said, now this public PR doesn't really matter since we also work around that in our API backend as well.
But, in that sense, since sending an empty value would produce the exact same result as not sending it, there's now zero reason users want to send an empty value and hence
omitempty
is an appropriate option here.