-
Notifications
You must be signed in to change notification settings - Fork 344
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
base: master
Are you sure you want to change the base?
Conversation
Codecov Report
@@ 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
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 186 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
@@ -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) |
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.
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 ladbhelpers.GetStatusByID
(and others). More work, but a better solution IMO.
Closes: #7321
Change status to 400 Bad request when creating DeliveryService without tenantId
Which Traffic Control components are affected by this PR?
What is the best way to verify this PR?
If this is a bugfix, which Traffic Control versions contained the bug?
PR submission checklist