You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficcontrol.apache.org by "ntheanh201 (via GitHub)" <gi...@apache.org> on 2023/10/24 07:59:36 UTC

[PR] change status to 400 Bad request [trafficcontrol]

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

   Closes: #7321 
   
   Change status to 400 Bad request when creating DeliveryService without tenantId
   <!-- **^ Add meaningful description above** --><hr/>
   
   ## Which Traffic Control components are affected by this PR?
   - 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. -->
   
   
   ## 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)
    -->
   
   
   ## PR submission checklist
   - [x] 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


Re: [PR] Fix Incorrect error message when creating a DS with insufficient Tenancy [trafficcontrol]

Posted by "ntheanh201 (via GitHub)" <gi...@apache.org>.
ntheanh201 closed pull request #7848: Fix Incorrect error message when creating a DS with insufficient Tenancy
URL: https://github.com/apache/trafficcontrol/pull/7848


-- 
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: general-unsubscribe@attic.apache.org

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


Re: [PR] Fix Incorrect error message when creating a DS with insufficient Tenancy [trafficcontrol]

Posted by "ocket8888 (via GitHub)" <gi...@apache.org>.
ocket8888 commented on code in PR #7848:
URL: https://github.com/apache/trafficcontrol/pull/7848#discussion_r1379106740


##########
traffic_ops/traffic_ops_golang/deliveryservice/deliveryservices.go:
##########
@@ -388,7 +388,7 @@ func createV50(w http.ResponseWriter, r *http.Request, inf *api.APIInfo, ds tc.D
 		return nil, http.StatusInternalServerError, nil, sysErr
 	}
 	if authorized, err := isTenantAuthorized(inf, &ds); err != nil {
-		return nil, http.StatusInternalServerError, nil, fmt.Errorf("checking tenant: %w", err)
+		return nil, http.StatusBadRequest, err, fmt.Errorf("checking tenant: %w", err)

Review Comment:
   This exposes error information from connections with the database to API clients. One of two things should instead be done:
   * check here that the error returned by `isTenantAuthorized` does/doesn't represent a failure to find any matching rows and handle appropriately (404 if yes, 500 otherwise)
   * refactor `isTenantAuthorized` to instead return a third value which indicates whether any such Tenant could be found a la [`dbhelpers.GetStatusByID`](https://pkg.go.dev/github.com/apache/trafficcontrol@v7.0.1+incompatible/traffic_ops/traffic_ops_golang/dbhelpers#GetStatusByID) (and others). More work, but a better solution IMO.



-- 
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


Re: [PR] Fix Incorrect error message when creating a DS with insufficient Tenancy [trafficcontrol]

Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #7848:
URL: https://github.com/apache/trafficcontrol/pull/7848#issuecomment-1777820844

   ## [Codecov](https://app.codecov.io/gh/apache/trafficcontrol/pull/7848?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   > Merging [#7848](https://app.codecov.io/gh/apache/trafficcontrol/pull/7848?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) (89b14a2) into [master](https://app.codecov.io/gh/apache/trafficcontrol/commit/cb74c5b31ad0897ae428c49cdde861249cc901e1?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) (cb74c5b) will **increase** coverage by `8.93%`.
   > Report is 5 commits behind head on master.
   > The diff coverage is `n/a`.
   
   ```diff
   @@             Coverage Diff              @@
   ##             master    #7848      +/-   ##
   ============================================
   + Coverage     29.20%   38.14%   +8.93%     
     Complexity       98       98              
   ============================================
     Files           533      428     -105     
     Lines         71066    34301   -36765     
     Branches         90       90              
   ============================================
   - Hits          20753    13083    -7670     
   + Misses        48423    20035   -28388     
   + Partials       1890     1183     -707     
   ```
   
   | [Flag](https://app.codecov.io/gh/apache/trafficcontrol/pull/7848/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [golib_unit](https://app.codecov.io/gh/apache/trafficcontrol/pull/7848/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `53.86% <ø> (ø)` | |
   | [grove_unit](https://app.codecov.io/gh/apache/trafficcontrol/pull/7848/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `12.02% <ø> (ø)` | |
   | [t3c_unit](https://app.codecov.io/gh/apache/trafficcontrol/pull/7848/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `5.91% <ø> (ø)` | |
   | [traffic_monitor_unit](https://app.codecov.io/gh/apache/trafficcontrol/pull/7848/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `26.44% <ø> (?)` | |
   | [traffic_ops_unit](https://app.codecov.io/gh/apache/trafficcontrol/pull/7848/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [traffic_stats_unit](https://app.codecov.io/gh/apache/trafficcontrol/pull/7848/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `10.78% <ø> (ø)` | |
   | [unit_tests](https://app.codecov.io/gh/apache/trafficcontrol/pull/7848/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `32.32% <ø> (+6.57%)` | :arrow_up: |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
   
   [see 243 files with indirect coverage changes](https://app.codecov.io/gh/apache/trafficcontrol/pull/7848/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   
   :mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   


-- 
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