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 2020/04/22 16:34:53 UTC

[GitHub] [trafficcontrol] mitchell852 opened a new issue #4656: POST/PUT with an invalid foreign key in the request returns 404 instead of 400

mitchell852 opened a new issue #4656:
URL: https://github.com/apache/trafficcontrol/issues/4656


   ## I'm submitting a ...
   <!-- (check all that apply with "[x]") -->
   <!--- security vulnerability (STOP!! - see above)-->
   - [x] bug report
   - [ ] new feature / enhancement request
   - [ ] improvement request (usability, performance, tech debt, etc.)
   - [ ] other <!--(Please do not submit support requests here - see above)-->
   
   ## Traffic Control components affected ...
   <!-- (check all that apply with "[x]") -->
   - [ ] CDN in a Box
   - [ ] Documentation
   - [ ] Grove
   - [ ] Traffic Control Client
   - [ ] Traffic Monitor
   - [x] Traffic Ops
   - [ ] Traffic Ops ORT
   - [ ] Traffic Portal
   - [ ] Traffic Router
   - [ ] Traffic Stats
   - [ ] Traffic Vault
   - [ ] unknown
   
   ## Current behavior:
   Example:
   
   POST /api/2.0/regions {{"name":"my-region","division":9999}} results in a 404 due to the division=9999 not found. I think this is supposed to be a 400 Bad Request instead as 404 is reserved for http verb/resource path not found. 
   
   This also happens on PUT and seems to be global throughout the API.
   
   ## Expected / new behavior:
   POST /api/2.0/regions {{"name":"my-region","division":9999}} results in a 400 Bad Request and ideally a message along the lines of "Invalid division specified". 
   
   ## Minimal reproduction of the problem with instructions:
   POST /api/2.0/regions {{"name":"my-region","division":9999}} and observe the 404.
   
   <!--
   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.

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



[GitHub] [trafficcontrol] rawlinp commented on issue #4656: POST/PUT with an invalid foreign key in the request returns 404 instead of 400

Posted by GitBox <gi...@apache.org>.
rawlinp commented on issue #4656:
URL: https://github.com/apache/trafficcontrol/issues/4656#issuecomment-617955904


   I guess 409 would make more sense too.
   
   The naive fix would be to change `api.ParseDBError` to simply return 409 on missing FK errors, since it returns a 404 today, but then most of our endpoints will start returning 409s on PUTs when the resource doesn't actually exist, which should be a 404.
   
   So, this is not really going to be a simple fix. Most likely all API endpoints will need to be updated.


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

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



[GitHub] [trafficcontrol] ocket8888 commented on issue #4656: POST/PUT with an invalid foreign key in the request returns 404 instead of 400

Posted by GitBox <gi...@apache.org>.
ocket8888 commented on issue #4656:
URL: https://github.com/apache/trafficcontrol/issues/4656#issuecomment-617939260


   I would vote this be a `409 Conflict`


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

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