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

Deleting media object shows error #513

Open
gnufxela opened this issue Jul 22, 2024 · 8 comments
Open

Deleting media object shows error #513

gnufxela opened this issue Jul 22, 2024 · 8 comments
Labels
bug Something isn't working

Comments

@gnufxela
Copy link

gnufxela commented Jul 22, 2024

Tried to delete a media object(through browser). It seems to be deleted when looking at it through front end. I am running grampsweb docker container. However docker logs shows this error. (I deleted 2 objects).

Gramps 5.2.2
Gramps Web API 2.3.1
Gramps Web Frontend 24.7.0
Gramps QL 0.3.0
locale: en
multi-tree: false
task queue: true
grampsweb  | Exception possibly due to cache backend.
grampsweb  | Traceback (most recent call last):
grampsweb  |   File "/usr/local/lib/python3.11/dist-packages/gramps_webapi/api/util.py", line 536, in make_cache_key_thumbnails
grampsweb  |     obj = db_handle.get_media_from_handle(handle)
grampsweb  |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
grampsweb  |   File "/usr/local/lib/python3.11/dist-packages/gramps/gen/db/generic.py", line 1368, in get_media_from_handle
grampsweb  |     return self._get_from_handle(MEDIA_KEY, Media, handle)
grampsweb  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
grampsweb  |   File "/usr/local/lib/python3.11/dist-packages/gramps/gen/db/generic.py", line 1341, in _get_from_handle
grampsweb  |     raise HandleError("Handle %s not found" % handle)
grampsweb  | gramps.gen.errors.HandleError: Handle fa86664c5dc374901c1be088e98 not found
grampsweb  | 
grampsweb  | During handling of the above exception, another exception occurred:
grampsweb  | 
grampsweb  | Traceback (most recent call last):
grampsweb  |   File "/usr/local/lib/python3.11/dist-packages/flask_caching/__init__.py", line 374, in decorated_function
grampsweb  |     cache_key = make_cache_key(*args, **kwargs)
grampsweb  |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
grampsweb  |   File "/usr/local/lib/python3.11/dist-packages/gramps_webapi/api/util.py", line 538, in make_cache_key_thumbnails
grampsweb  |     abort_with_message(404, f"Handle {handle} not found")
grampsweb  |   File "/usr/local/lib/python3.11/dist-packages/gramps_webapi/api/util.py", line 655, in abort_with_message
grampsweb  |     raise exc
grampsweb  | werkzeug.exceptions.HTTPException: 404 Not Found: Handle fa86664c5dc374901c1be088e98 not found
grampsweb  | Exception possibly due to cache backend.
grampsweb  | Traceback (most recent call last):
grampsweb  |   File "/usr/local/lib/python3.11/dist-packages/gramps_webapi/api/util.py", line 536, in make_cache_key_thumbnails
grampsweb  |     obj = db_handle.get_media_from_handle(handle)
grampsweb  |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
grampsweb  |   File "/usr/local/lib/python3.11/dist-packages/gramps/gen/db/generic.py", line 1368, in get_media_from_handle
grampsweb  |     return self._get_from_handle(MEDIA_KEY, Media, handle)
grampsweb  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
grampsweb  |   File "/usr/local/lib/python3.11/dist-packages/gramps/gen/db/generic.py", line 1341, in _get_from_handle
grampsweb  |     raise HandleError("Handle %s not found" % handle)
grampsweb  | gramps.gen.errors.HandleError: Handle fa871f92b6761f31478482573be not found
grampsweb  | 
grampsweb  | During handling of the above exception, another exception occurred:
grampsweb  | 
grampsweb  | Traceback (most recent call last):
grampsweb  |   File "/usr/local/lib/python3.11/dist-packages/flask_caching/__init__.py", line 374, in decorated_function
grampsweb  |     cache_key = make_cache_key(*args, **kwargs)
grampsweb  |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
grampsweb  |   File "/usr/local/lib/python3.11/dist-packages/gramps_webapi/api/util.py", line 538, in make_cache_key_thumbnails
grampsweb  |     abort_with_message(404, f"Handle {handle} not found")
grampsweb  |   File "/usr/local/lib/python3.11/dist-packages/gramps_webapi/api/util.py", line 655, in abort_with_message
grampsweb  |     raise exc
grampsweb  | werkzeug.exceptions.HTTPException: 404 Not Found: Handle fa871f92b6761f31478482573be not found

Let me tack on 1 other issues I am facing that I might be potentially related(maybe not too):

  1. I also tried to set up S3 storage (on non AWS platform), I am not sure it is set up successfully.
    I was expecting that when I upload a jpeg, it would show up in my bucket. That did not happen.

I am not sure this error is related though. I did double check that AWS_SECRET_ACCESS_KEY , AWS_ACCESS_KEY_ID and AWS_ENDPOINT_URL are set in environment(inside the running container). Confirmed via python shell boto3 library that I can get access to the bucket. I didn't see other errors in the log. MEDIA_BASE_DIR="s3://<bucket-name>" is also set in config.cfg.

@DavidMStraub
Copy link
Member

Hi,

the error you pasted shows that Web API looks for a media object (not media file) and doesn't find it in the database. Is that the one you deleted? If yes, the question is why it's still being looked for. Can you check the browser console which API call triggers the 404, and when opening which view?

Concerning S3: yes, that's how it's supposed to work - working for me. Btw AWS_ENDPOINT_URL can be left empty when you use AWS itself.

@DavidMStraub DavidMStraub added the question Further information is requested label Jul 22, 2024
@gnufxela
Copy link
Author

gnufxela commented Jul 23, 2024

0dec5bd1.js:324 
        
        
       GET https://<domain>/api/media/fa8a9a809291757e15aab1ae211?locale=en&profile=all&backlinks=true&extend=all 404 (Not Found)
Dn @ 0dec5bd1.js:324
_updateData @ 0dec5bd1.js:5811
(anonymous) @ 0dec5bd1.js:5811
jn @ 0dec5bd1.js:324
await in jn (async)
On @ 0dec5bd1.js:324
(anonymous) @ 0dec5bd1.js:11668
Promise.then (async)
_submit @ 0dec5bd1.js:11668
handleEvent @ 0dec5bd1.js:2
0dec5bd1.js:324 
        
        
       GET https://<domain>/api/media/fa8a9a809291757e15aab1ae211?locale=en&profile=all&backlinks=true&extend=all 404 (Not Found)
Dn @ 0dec5bd1.js:324
_updateData @ 0dec5bd1.js:5811
(anonymous) @ 0dec5bd1.js:5811
as @ 0dec5bd1.js:389
_deleteSelf @ 0dec5bd1.js:3208
await in _deleteSelf (async)
as @ 0dec5bd1.js:389
_deleteObject @ 0dec5bd1.js:936
_handleDialog @ 0dec5bd1.js:936
handleEvent @ 0dec5bd1.js:2
emitNotification @ 0dec5bd1.js:407
notifyClosed @ 0dec5bd1.js:407
(anonymous) @ 0dec5bd1.js:407
setTimeout (async)
e.close @ 0dec5bd1.js:407
e.handleClick @ 0dec5bd1.js:407
0dec5bd1.js:324 
        
        
       GET https://<domain>/api/media/fa8aa1357184544946351992579?locale=en&profile=all&backlinks=true&extend=all 404 (Not Found)
Dn @ 0dec5bd1.js:324
_updateData @ 0dec5bd1.js:5811
(anonymous) @ 0dec5bd1.js:5811
as @ 0dec5bd1.js:389
_deleteSelf @ 0dec5bd1.js:3208
await in _deleteSelf (async)
as @ 0dec5bd1.js:389
_deleteObject @ 0dec5bd1.js:936
_handleDialog @ 0dec5bd1.js:936
handleEvent @ 0dec5bd1.js:2
emitNotification @ 0dec5bd1.js:407
notifyClosed @ 0dec5bd1.js:407
(anonymous) @ 0dec5bd1.js:407
setTimeout (async)
e.close @ 0dec5bd1.js:407
e.handleClick @ 0dec5bd1.js:407
0dec5bd1.js:324 
        
        
       GET https://<domain>/api/media/fa8aa1357184544946351992579/face_detection 404 (Not Found)
Dn @ 0dec5bd1.js:324
_updateData @ 0dec5bd1.js:2725
as @ 0dec5bd1.js:389
_deleteSelf @ 0dec5bd1.js:3208
await in _deleteSelf (async)
as @ 0dec5bd1.js:389
_deleteObject @ 0dec5bd1.js:936
_handleDialog @ 0dec5bd1.js:936
handleEvent @ 0dec5bd1.js:2
emitNotification @ 0dec5bd1.js:407
notifyClosed @ 0dec5bd1.js:407
(anonymous) @ 0dec5bd1.js:407
setTimeout (async)
e.close @ 0dec5bd1.js:407
e.handleClick @ 0dec5bd1.js:407

Console log here. I noticed that backend message shows up when I deleted the media object.

0dec5bd1.js:324 
        
        
       GET https://<domain>/api/metadata/ 401 (Unauthorized)
Dn @ 0dec5bd1.js:324
_loadDbInfo @ 0dec5bd1.js:12368
connectedCallback @ 0dec5bd1.js:12368
(anonymous) @ 0dec5bd1.js:12042

This also shows up the first time i refreshed the page after deleting(Doesn't seem to be consistent to me).

Sorry not sure what's the easiest way to verify Handle fa871f92b6761f31478482573be == the media object that is uploaded, then deleted?

@gnufxela

This comment was marked as off-topic.

@DavidMStraub
Copy link
Member

Please open a discussion or forum post on your S3 setup questions, this is unrelated to the issue.

@DavidMStraub
Copy link
Member

There is not enough information in this issue to understand if something is wrong with Gramps Web API. I suggest to run check & repair on the database and see if the error persists. If it does, it is crucial to check which API call actually fails. You can use the network tab in the browser dev console to find out.

@gnufxela
Copy link
Author

gnufxela commented Oct 20, 2024

Hello. It's not critical to me. I am able to reproduce it.

It is looking for the file I just deleted. The error does not persist. It's likely a front end bug. Where after I deleted the file, the front end does not know that right away. So it looks for those files. In fact, I can see that deleted file still listed in the List view. Refreshing the page makes the error go away.

In the browser dev cosole, I see api/media/.../face_detection and api/media/...?locale=en&profile=all&backlinks=true&extend=all errors. These errors pop up right after I deleted the files. After deleting the file, I am bounced directly to the home page.

Since it is not critical, you may feel free to punt on this issue. Thank you.

@DavidMStraub
Copy link
Member

Thanks for providing more detail, I think I see what the problem is. The deletion happens in edit mode, after deletion the frontend shows the home page (since the deleted object does not exist anymore), but the media object view (which is just hidden) is still in edit mode and tries to fetch the thumbnail, which errors.

@DavidMStraub DavidMStraub added bug Something isn't working and removed question Further information is requested labels Oct 20, 2024
@DavidMStraub
Copy link
Member

DavidMStraub commented Oct 20, 2024

Will shift to the frontend repo.

@DavidMStraub DavidMStraub transferred this issue from gramps-project/gramps-web-api Oct 20, 2024
@DavidMStraub DavidMStraub changed the title Deleting media object Deleting media object shows error Oct 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants