FrancisG-Massey / Capstone2016

4 stars 0 forks source link

PUT https://www.nestnz.org/api/trap/4 500 (Internal Server Error) #165

Closed MrMJLee closed 8 years ago

MrMJLee commented 8 years ago

Editing a trap returns a 500 internal server error. Maybe on web side problem.

MrMJLee commented 8 years ago

Somehow it worked for one time. Accidentally modified the trap number 1 in Manawatu Tawa loop line. Sorry Sam haha

sam-hunt commented 8 years ago

I really need to work out which 500 errors are SQLExceptions caused by constraint violations at some point, and repackage them as 400 bad requests which they are.

So is this an API bug or just a one-off client-side usage error? I can check the tomcat logs when I get home if you want, just let me know.

MrMJLee commented 8 years ago

It worked just for that trap. Same request now doesn't work for other traps in other traplines. Only the Tawa loop works at the moment

MrMJLee commented 8 years ago

I will close this issue as @samhunt0 fixed this from API

MrMJLee commented 8 years ago

Having same issue.

sam-hunt commented 8 years ago

Please check the tomcat log and post details if this is urgent. Alternatively I'll be home in 1-2 hours and we can debug it then. I seriously doubt that this is the same bug as the fix for this is on master and updated on EC2.

sam-hunt commented 8 years ago

Okay I've scanned the last 35 requests made to the API. While there are 5 failed responses with 500 https codes, there is no evidence of any bugs in the API. These are all mislabeled 400 bad requests as was discussed earlier. Please review the following summaries:

  1. POST /trap (500) (1 error) Missing trap-type parameter. Check that this is included in the request body and named correctly: "traptype_id" OR Ensure that the trapline (1) has a default traptype set (this may be null).
  2. POST /trap (500) (4 errors) Invalid longitude value (190)

As for the first error, I think I'll add a not-null constraint to the default traptype and bait fields on trapline. Its not a perfect solution, but it will do.

As for the seconds error, Review issue #156. Please implement the web-app UI restriction so users cannot enter invalid coordinate values As this has already been implemented in the API, the database no longer accepts invalid latitude or longitude values.

sam-hunt commented 8 years ago

Closing as remaining errors should actually 400 not 500 as noted. This will be continued under issue #176.