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

Add validate_tags util to check that tags are an array of strings #218

Merged
merged 5 commits into from
Jan 28, 2020

Conversation

zippolyte
Copy link
Contributor

@zippolyte zippolyte commented Jan 28, 2020

What does this PR do?

SSIA
fixes #50

Verification Process

Unit tests

Review checklist (to be filled by reviewers)

  • Feature or bug fix MUST have appropriate tests (unit, integration, etc...)
  • PR title must be written as a CHANGELOG entry (see why)
  • Files changes must correspond to the primary purpose of the PR as described in the title (small unrelated changes should have their own PR)
  • PR must have one changelog/ label attached. If applicable it should have the backward-incompatible label attached.
  • PR should not have do-not-merge/ label attached.
  • If Applicable, issue must have kind/ and severity/ labels attached at least.

@zippolyte zippolyte requested a review from a team as a code owner January 28, 2020 16:32
@@ -205,4 +205,13 @@ def Dogapi.find_localhost
raise $ERROR_INFO unless $ERROR_INFO.class.name == 'Errno::ENOENT'
@@hostname = Addrinfo.getaddrinfo(Socket.gethostname, nil, nil, nil, nil, Socket::AI_CANONNAME).first.canonname
end

def Dogapi.validate_tags(tags)
unless tags.is_a? Array
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not this kind of precious stone expert but what if tags is null?

@zippolyte zippolyte merged commit 8a3b4e4 into master Jan 28, 2020
@zippolyte zippolyte deleted the hippo/vt branch January 28, 2020 18:15
@miketheman
Copy link
Contributor

What calls validate_tags??

@zippolyte
Copy link
Contributor Author

It will be up to the user to call that utility function in order to validate the tags they pass to the API.

@miketheman
Copy link
Contributor

That seems counter to the original report.
There doesn't seem to be a change log or docs update with this, so how would a user know? Why make it the user responsibility, when you can call it for them?

@zippolyte
Copy link
Contributor Author

True this doesn't exactly answer the original report, I'll leave a comment on the issue explaining our reasoning with this.

We didn't want to add this validation to every endpoint that manipulates tags because it can cause some performance drop given that we have to check for every individual tag.
Additionally, given this report never gained much traction, we didn't want to make such a change to every single endpoint and risk breaking things for current users.

However, if there is a real need for this, we now at least provide this utility function for a user to easily validate their tags, an for us to later add this to every endpoint.
A changelog entry will be added when the release is made for users to know about this, plus a comment on the original issue.

@zippolyte zippolyte added the changelog/Added Added features results into a minor version bump label Feb 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog/Added Added features results into a minor version bump
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ensure that the "tags" parameter is always a list
3 participants