-
Notifications
You must be signed in to change notification settings - Fork 12
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
Improve error reporting when an operation fails #1331
Comments
@rem0g are you busy trying to upload a zip file? In the error log it was giving errors about the api token. |
Yes, sometimes video_upload returns whole django HTML template so my script doesnt know how to interprent that. It will keep for looping that same video file, so error reporting should be always in JSON format. Sometimes i'm getting Failed to upload message, though there is no reason attached as why it happens. I will continue to run the script as some videos are uploaded succesfully, but I am not satisfied with how Signbank handles the video upload process so we will need another method to handle the videos as in the future we will have to process thousands of videos every week (happening now). I am getting fails with gloss with special chars for example: Also Signbank notifies the video is not h264 but yet the video is there on Signbank. @Woseseltops i think the video upload process needs a do-over; |
@rem0g what is a good way to report errors? Returning a JsonResponse with the error? I'm trying to add checks into the APIs for example sentences. |
Indeed @Jetske , something like this: return JsonResponse({'error': 'Invalid request'}, status=400) In addition to that, using the correct error code would be even better:
@rem0g , I'll create a separate issue for your video upload suggestions! |
The error reporting I added for gloss updates (Batch Edit and API) reports type errors, for example choices that don't exist. |
@rem0g have you been able to use the NME API functions all right? |
Is there anything for "type checking"? Or do we make a new status code for this? |
@rem0g do you know what specific API you called that reported that it failed but it did not? It's probably something with variable scoping in the various branches. And you don't want the check whether it's h264. I think there was a conflict between using a json field "status" versus e.g., "updatestatus". Is it possible that the one that reported an error but still seemed to have worked was "replacing" a video? |
Adjusted json dictionary results to include in various branches Change status json keyword to importstatus
@rem0g I can see that there are Disney video files:
Of the above, DISNEY-C and DISNEY-D do not show on signbank, in spite of the video files existing. https://signbank.cls.ru.nl/dictionary/gloss/48427 https://signbank.cls.ru.nl/dictionary/gloss/48428 @Woseseltops @vanlummelhuizen any idea what's going on here? [UPDATE] With numerous repeated zip imports I was able to get the second code branch to be taken. It's when there is no video yet. The path is wrong there. The branch is only when there is no video object at all. I had to remove objects and files to get that branch to be taken. I suspect seeing that so many import operations were done that the rest are failing for other reasons, but because of an initial wrong path. The video code does not actually delete files because of a setting in default. But it has try-except calls that seem to just ignore. |
In the video history I can see you uploaded the DISNEY videos numerous times. (74 times) Below, you can see the path stored in the object is wrong. (Need to figure out where it is setting this wrong in the code. it's stored as a relative path, but it's displayed here as a full path. the relative path is wrong but the video is stored correctly on the file system.) |
The above error is high priority!!! The code does not know it's doing anything wrong. I can see that the "create still image" is using a file in the wrong location: Video file: /home/susan/signbank/writable/SLIM-D-48844.mp4 It's missing the "glossvideo/NGT/SL" from the path. But I can't see where it is getting this from, nor where the method is being called. (There are numerous imports from different python files.) The code is unaware that it is doing anything wrong / does not report errors, because of try-except on OS calls, so it basically does "pass" on some low-level things outside of Django. But hypothetically, what would be the behaviour if the file system/database is not wanting to save? Just crash an operation that is supposed to import hundreds of videos? (Is importing a bunch of videos "one" operation?) |
Fixed path of unzipped new video in GlossVideo object
#1331: Improve error reporting (phase 1)
Up to here, the repairs commented about above:
have been deployed. Regarding the first one, if you go to the Dataset Media Manager (via the Manage Datasets page) you will see for NGT that the videos previously shown as "not mp4" can now be imported (the probe is not applied to the files anymore). I removed the video files and their gloss video objects that were in "writable" instead of in "writable/NGT/XX" |
I would say: return JsonResponse({'error': 'Explanation of what went wrong type checking.'}, status=400) |
Swagger isn't logged in, it's only using the API token. |
The uploaded (unzipped) videos are first put in another location, in the import folder. |
Revised missing videos view url to show videos that have a file but no GlossVideo object.
@vanlummelhuizen I made the changes for the ZIP code you showed above. It took a while to figure out what was wrong. The the dataset folders NEED to be already created in glossvideo. |
Up to here, the fixes shown above have all been deployed on signbank. |
I found this in the logs:
File "/var/www/env/lib/python3.12/site-packages/django/core/handlers/base.py", line 197, in _get_response
|
|
Why is there an "/etc/passwd" stuck on the end of the url? It's even worse here:
|
How to fix this, or is there nothing to do about these malicious urls? |
So if a user tries to enter a bogus URL to a video or image, then try except the only line of code above and do a "Forbidden" ? What are they trying to do? Get the server to switch to a console or something? |
|
Here's more recent, I decided to skip those 200000 lines of hackers.
So after a number of successful API gloss updates, the database is locked. The database locked is after a gloss.save() @Woseseltops what to do about this?
|
Here it is in context:
A package is done, then 8 update gloss calls, then the database is locked. @Woseseltops @vanlummelhuizen look here. (There are no other operations between the API calls. The database getting locked is not caused by other users, but by the API calls.) |
Question: Can we force the API calls to fail if the database is locked? Otherwise the stuff afterwards just keeps causing errors. Django ought to refuse new API requests. |
@vanlummelhuizen what is the best kind of response to "revoke" all of those "hacker" type url requests? #1331 (comment) I got rid of the search parameters by using the query parameters. But that is not all-encompassing. |
I removed the bogus user accounts that showed up in the database last week. |
|
|
About moving away from SQLite: #673 About request from hackers: Django seems to handle those correctly, responding with error 500. If you want to know more about security (hardening) search for 'django security hardening'. One thing I came across that might be of use: https://djcheckup.com/. About bogus user registrations: we propably needs to review registrations once in a while. But I think it should be an Amsterdam task. Perhaps we could make a cronjob that make a daily email with al new registration and send that to Ulrika for instance. |
Here is where the database is with the bogus users still in it (tensusers): |
@vanlummelhuizen do I need to add a try-except on all the save methods? And throw an error to the API if the database is locked? I don't know if methods that fail clean up after themselves. |
This should reject junk at end as no matching url.
Instead of just try-except pass around error messages to report back. Also for transactions that fail. Also for file system errors.
This is non-trivial.
Kindly report use cases (including API) where something is going wrong but this isn't reported sufficiently.
The text was updated successfully, but these errors were encountered: