You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficcontrol.apache.org by GitBox <gi...@apache.org> on 2022/05/20 15:58:56 UTC

[GitHub] [trafficcontrol] rimashah25 opened a new pull request, #6847: Fixed API v4 /servers result for query param {profileName}

rimashah25 opened a new pull request, #6847:
URL: https://github.com/apache/trafficcontrol/pull/6847

   <!--
   Thank you for contributing! Please be sure to read our contribution guidelines: https://github.com/apache/trafficcontrol/blob/master/CONTRIBUTING.md
   If this closes or relates to an existing issue, please reference it using one of the following:
   
   Closes: #ISSUE
   Related: #ISSUE
   
   If this PR fixes a security vulnerability, DO NOT submit! Instead, contact
   the Apache Traffic Control Security Team at security@trafficcontrol.apache.org and follow the
   guidelines at https://apache.org/security regarding vulnerability disclosure.
   -->
   
   Closes: https://github.com/apache/trafficcontrol/issues/6834
   
   
   <!-- **^ Add meaningful description above** --><hr/>
   
   ## Which Traffic Control components are affected by this PR?
   <!-- Please delete all components from this list that are NOT affected by this PR.
   Feel free to add the name of a tool or script that is affected but not on the list.
   -->
   - Documentation
   - Traffic Ops
   
   ## What is the best way to verify this PR?
   <!-- Please include here ALL the steps necessary to test your PR.
   If your PR has tests (and most should), provide the steps needed to run the tests.
   If not, please provide step-by-step instructions to test the PR manually and explain why your PR does not need tests. -->
   Create two servers, one via APIv4 (and assign multiple profiles, eg:`GLOBAL, TRAFFIC_OPS`) and one via APIv3(eg: `TRAFFIC_OPS`)
   
   curl `https://localhost:8443/api/4.0/servers?profileName=<profile_name>`
   curl  `https://localhost:8443/api/3.0/servers?profileId=<profile_id>`
   
   In 4.0, if queried for `profileName=TRAFFIC_OPS`, one should see 2 results.
   In 3.0, if queried for `profileId=3`, one should see only one result (since `TRAFFIC_OPS` is at index 0 only in one server).
   
   ## If this is a bugfix, which Traffic Control versions contained the bug?
   <!-- Delete this section if the PR is not a bugfix, or if the bug is only in the master branch.
   Examples:
   - 5.1.2
   - 5.1.3 (RC1)
    -->
   6.1.0
   
   ## PR submission checklist
   - [ ] This PR has tests <!-- If not, please delete this text and explain why this PR does not need tests. -->
   - [x] This PR has documentation <!-- If not, please delete this text and explain why this PR does not need documentation. -->
   - [x] This PR has a CHANGELOG.md entry <!-- A fix for a bug from an ATC release, an improvement, or a new feature should have a changelog entry. -->
   - [x] This PR **DOES NOT FIX A SERIOUS SECURITY VULNERABILITY** (see [the Apache Software Foundation's security guidelines](https://apache.org/security) for details)
   
   <!--
   Licensed to the Apache Software Foundation (ASF) under one
   or more contributor license agreements.  See the NOTICE file
   distributed with this work for additional information
   regarding copyright ownership.  The ASF licenses this file
   to you under the Apache License, Version 2.0 (the
   "License"); you may not use this file except in compliance
   with the License.  You may obtain a copy of the License at
   
       http://www.apache.org/licenses/LICENSE-2.0
   
   Unless required by applicable law or agreed to in writing,
   software distributed under the License is distributed on an
   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   KIND, either express or implied.  See the License for the
   specific language governing permissions and limitations
   under the License.
   -->
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@trafficcontrol.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [trafficcontrol] ocket8888 merged pull request #6847: Fixed API v4 `/servers` result for query param {profileName}

Posted by GitBox <gi...@apache.org>.
ocket8888 merged PR #6847:
URL: https://github.com/apache/trafficcontrol/pull/6847


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@trafficcontrol.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [trafficcontrol] ericholguin commented on a diff in pull request #6847: Fixed API v4 `/servers` result for query param {profileName}

Posted by GitBox <gi...@apache.org>.
ericholguin commented on code in PR #6847:
URL: https://github.com/apache/trafficcontrol/pull/6847#discussion_r878508427


##########
traffic_ops/traffic_ops_golang/server/servers.go:
##########
@@ -974,10 +992,18 @@ func getServers(h http.Header, params map[string]string, tx *sqlx.Tx, user *auth
 		return nil, 0, util.JoinErrs(errs), nil, http.StatusBadRequest, nil
 	}
 
-	countQuery := serverCountQuery + queryAddition + where
+	var queryString, countQueryString string
+	queryString = selectQuery + joinProfileV3
+	countQueryString = serverCountQuery + joinProfileV3
+	if _, ok := params["profileName"]; ok {

Review Comment:
   Checking for key here causes an Internal Server Error when making a 
   
   `GET` request to: `/api/v3/servers?profileNames={}` 
   
   Normally if a parameter doesn't exist it is ignored. Changing the check to `if version.Major >= 4 {` like above should work



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@trafficcontrol.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [trafficcontrol] ericholguin commented on a diff in pull request #6847: Fixed API v4 `/servers` result for query param {profileName}

Posted by GitBox <gi...@apache.org>.
ericholguin commented on code in PR #6847:
URL: https://github.com/apache/trafficcontrol/pull/6847#discussion_r878508427


##########
traffic_ops/traffic_ops_golang/server/servers.go:
##########
@@ -974,10 +992,18 @@ func getServers(h http.Header, params map[string]string, tx *sqlx.Tx, user *auth
 		return nil, 0, util.JoinErrs(errs), nil, http.StatusBadRequest, nil
 	}
 
-	countQuery := serverCountQuery + queryAddition + where
+	var queryString, countQueryString string
+	queryString = selectQuery + joinProfileV3
+	countQueryString = serverCountQuery + joinProfileV3
+	if _, ok := params["profileName"]; ok {

Review Comment:
   Checking for key here causes an Internal Server Error when making a `GET` request to: `/api/v3/servers?profileNames={}` normally if a parameter doesn't exist it is ignored. Changing the check to `if version.Major >= 4 {` like above should work



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@trafficcontrol.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [trafficcontrol] ericholguin commented on a diff in pull request #6847: Fixed API v4 `/servers` result for query param {profileName}

Posted by GitBox <gi...@apache.org>.
ericholguin commented on code in PR #6847:
URL: https://github.com/apache/trafficcontrol/pull/6847#discussion_r878504944


##########
docs/source/api/v4/servers.rst:
##########
@@ -51,7 +51,7 @@ Request Structure
 	+----------------+----------+-------------------------------------------------------------------------------------------------------------------+
 	| id             | no       | Return only the server with this integral, unique identifier                                                      |
 	+----------------+----------+-------------------------------------------------------------------------------------------------------------------+
-	| profileId      | no       | Return only those servers that are using the :term:`Profile` that has this :ref:`profile-id`                      |
+	| profileName    | no       | Return only those servers that are using the :term:`Profile` that has this :ref:`profile-name`                      |

Review Comment:
   Extra spaces causing the malformed table issue



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@trafficcontrol.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [trafficcontrol] rimashah25 commented on a diff in pull request #6847: Fixed API v4 `/servers` result for query param {profileName}

Posted by GitBox <gi...@apache.org>.
rimashah25 commented on code in PR #6847:
URL: https://github.com/apache/trafficcontrol/pull/6847#discussion_r878538773


##########
traffic_ops/traffic_ops_golang/server/servers.go:
##########
@@ -974,10 +992,18 @@ func getServers(h http.Header, params map[string]string, tx *sqlx.Tx, user *auth
 		return nil, 0, util.JoinErrs(errs), nil, http.StatusBadRequest, nil
 	}
 
-	countQuery := serverCountQuery + queryAddition + where
+	var queryString, countQueryString string
+	queryString = selectQuery + joinProfileV3
+	countQueryString = serverCountQuery + joinProfileV3
+	if _, ok := params["profileName"]; ok {

Review Comment:
   `profileName` is the query param not `profileNames` and changed if condition.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@trafficcontrol.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [trafficcontrol] ericholguin commented on a diff in pull request #6847: Fixed API v4 `/servers` result for query param {profileName}

Posted by GitBox <gi...@apache.org>.
ericholguin commented on code in PR #6847:
URL: https://github.com/apache/trafficcontrol/pull/6847#discussion_r878508427


##########
traffic_ops/traffic_ops_golang/server/servers.go:
##########
@@ -974,10 +992,18 @@ func getServers(h http.Header, params map[string]string, tx *sqlx.Tx, user *auth
 		return nil, 0, util.JoinErrs(errs), nil, http.StatusBadRequest, nil
 	}
 
-	countQuery := serverCountQuery + queryAddition + where
+	var queryString, countQueryString string
+	queryString = selectQuery + joinProfileV3
+	countQueryString = serverCountQuery + joinProfileV3
+	if _, ok := params["profileName"]; ok {

Review Comment:
   Checking for key here causes an Internal Server Error when making a 
   
   `GET` request to: `/api/3.0/servers?profileName={}` 
   
   Normally if a parameter doesn't exist it is ignored. Changing the check to `if version.Major >= 4 {` like above should work



##########
traffic_ops/traffic_ops_golang/server/servers.go:
##########
@@ -974,10 +992,18 @@ func getServers(h http.Header, params map[string]string, tx *sqlx.Tx, user *auth
 		return nil, 0, util.JoinErrs(errs), nil, http.StatusBadRequest, nil
 	}
 
-	countQuery := serverCountQuery + queryAddition + where
+	var queryString, countQueryString string
+	queryString = selectQuery + joinProfileV3
+	countQueryString = serverCountQuery + joinProfileV3
+	if _, ok := params["profileName"]; ok {

Review Comment:
   My mistake thats a typo from me



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@trafficcontrol.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org