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

Fix Incorrect error message when creating a DS with insufficient Tenancy #7848

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ntheanh201
Copy link
Contributor

@ntheanh201 ntheanh201 commented Oct 24, 2023

Closes: #7321

Change status to 400 Bad request when creating DeliveryService without tenantId


Which Traffic Control components are affected by this PR?

  • Traffic Ops

What is the best way to verify this PR?

If this is a bugfix, which Traffic Control versions contained the bug?

PR submission checklist

@ntheanh201 ntheanh201 changed the title change status to 400 Bad request Fix Incorrect error message when creating a DS with insufficient Tenancy Oct 24, 2023
@codecov
Copy link

codecov bot commented Oct 24, 2023

Codecov Report

Merging #7848 (89b14a2) into master (cb74c5b) will increase coverage by 2.71%.
Report is 5 commits behind head on master.
The diff coverage is 0.00%.

@@             Coverage Diff              @@
##             master    #7848      +/-   ##
============================================
+ Coverage     29.20%   31.92%   +2.71%     
  Complexity       98       98              
============================================
  Files           533      719     +186     
  Lines         71066    82789   +11723     
  Branches         90      970     +880     
============================================
+ Hits          20753    26428    +5675     
- Misses        48423    54199    +5776     
- Partials       1890     2162     +272     
Flag Coverage Δ
golib_unit 53.86% <ø> (ø)
grove_unit 12.02% <ø> (ø)
t3c_unit 5.91% <ø> (ø)
traffic_monitor_unit 26.44% <ø> (?)
traffic_ops_integration 69.42% <ø> (ø)
traffic_ops_unit 21.68% <0.00%> (ø)
traffic_portal_v2 74.35% <ø> (?)
traffic_stats_unit 10.78% <ø> (ø)
unit_tests 29.25% <0.00%> (+3.50%) ⬆️
v3 57.79% <ø> (ø)
v4 79.18% <ø> (ø)
v5 78.58% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
...fic_ops_golang/deliveryservice/deliveryservices.go 17.67% <0.00%> (ø)

... and 186 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@ocket8888 ocket8888 added bug something isn't working as intended Traffic Ops related to Traffic Ops low impact affects only a small portion of a CDN, and cannot itself break one labels Nov 1, 2023
@ocket8888 ocket8888 self-assigned this Nov 1, 2023
@@ -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)
Copy link
Contributor

Choose a reason for hiding this comment

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

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 (and others). More work, but a better solution IMO.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something isn't working as intended low impact affects only a small portion of a CDN, and cannot itself break one Traffic Ops related to Traffic Ops
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect error message when creating a DS with insufficient Tenancy
2 participants