We're updating the issue view to help you get more done. 

Mass import: bookmark search crashes when archivist has work bookmarks

Description

To prevent duplicates, the mass import API checks if the archivist has already bookmarked the external work currently being bookmarked. To do this, it filters the archivist's bookmarks on bookmarkable with a url field set to the external work's url. Unfortunately, if the bookmarkable is a work or series, it doesn't have a url field so this code crashes if the archivist has ever bookmarked anything that isn't an external work.

Testing Notes
This is covered by an automated test but can be tested manually from a REST client by sending the following POST request (this format can be pasted into RubyMine, or adapted to a REST client - token for Test will be provided on request):

1 2 3 4 5 6 POST https://test.archiveofourown.org/api/v2/bookmarks/search Accept: application/json Authorization: Token token={{token}} Content-Type: application/json { "archivist": "testy", "bookmarks": [{"url":"http://example.com"}] }

Right now, this test will return the following response:

1 2 3 4 { "status": "internal_server_error", "messages": "An error occurred in the Archive code: undefined method `url' for #<Work:0x007fcb31b322f8>" }

But after the fix the expect response should be:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 { "status": "ok", "messages": [ "Successfully searched bookmarks for archivist 'testy'" ], "bookmarks": [ { "status": "not_found", "archive_url": "", "original_id": "123", "original_url": "http://example.com", "messages": [ "There is no bookmark for testy and the URL http://example.com" ] } ] }

Environment

Status

Assignee

Ariana

Reporter

Ariana

Roadmap

Work Importing

Priority

Medium

Affects versions

0.9.226

Fix versions

Components

BackEnd

Difficulty

Medium

Required Access Level

Archivist

Milestone

Internal 0.9