benwbrum / fromthepage

FromThePage is a wiki-like application for crowdsourcing transcription of handwritten documents.
http://fromthepage.com
GNU Affero General Public License v3.0
171 stars 51 forks source link

authorization failure when enabling document sets in collection settings #4340

Closed saracarl closed 1 month ago

saracarl commented 1 month ago

SusanGrey at LVA can't enable document sets. The setting isn't saved.

javascript console has this:

Failed to load resource: the server responded with a status of 422 (Unprocessable Entity) on: https://fromthepage.com/collection/update/virginia-untold-commonwealth-causes

And I found this in the log:

I, [2024-09-19T13:42:13.736468 #2941612]  INFO -- : Started GET "/collection/update/virginia-untold-commonwealth-causes" for 66.249.83.113 at 2024-09-19 13:42:13 +0000
I, [2024-09-19T13:42:13.739955 #2941612]  INFO -- : Processing by CollectionController#update as HTML
I, [2024-09-19T13:42:13.740292 #2941612]  INFO -- :   Parameters: {"id"=>"virginia-untold-commonwealth-causes"}
I, [2024-09-19T13:42:13.740358 #2941512]  INFO -- :   Rendered collection/show.html.slim within layouts/application (Duration: 372.6ms | Allocations: 222278)
I, [2024-09-19T13:42:13.743163 #2941612]  INFO -- : [ahoy] Visit excluded
I, [2024-09-19T13:42:13.746704 #2941612]  INFO -- : Redirected to https://fromthepage.com/dashboard
I, [2024-09-19T13:42:13.747124 #2941612]  INFO -- : Filter chain halted as :authorized? rendered or redirected
I, [2024-09-19T13:42:13.748095 #2941612]  INFO -- : Completed 302 Found in 7ms (ActiveRecord: 0.4ms | Allocations: 2739)
I, [2024-09-19T13:42:13.748451 #2941612]  INFO -- : Oink Action: collection#update
I, [2024-09-19T13:42:13.748750 #2941612]  INFO -- : Memory usage: 2888644 | PID: 2941612
I, [2024-09-19T13:42:13.748976 #2941612]  INFO -- : Instantiation Breakdown: Total: 0
I, [2024-09-19T13:42:13.749182 #2941612]  INFO -- : Oink Log Entry Complete

I'm logged in as the lva account to do this, so I don't know why authorized? would be failing, which is how I read that.

They do have an existing document set on this collection (which is also a bit weird); I'm wondering if that document set might be owned by a different user or have different authorization?

saracarl commented 1 month ago

I was able to change the description and add tags to this collection, so it's not a generalized settings problem.

I also enabled document sets on a different customer's collection yesterday, so it's not a generalized document set settings problem.

benwbrum commented 1 month ago

Here's what I see in the logs when I reproduced this:

I, [2024-09-19T18:41:31.838886 #2941536]  INFO -- : Started POST "/collection/update/virginia-untold-commonwealth-causes" 
for 12.236.180.18 at 2024-09-19 18:41:31 +0000
I, [2024-09-19T18:41:31.841106 #2941536]  INFO -- : Processing by CollectionController#update as JS
I, [2024-09-19T18:41:31.841332 #2941536]  INFO -- :   Parameters: {"authenticity_token"=>"NtTeOyRksY28MkxGwS7QTNDe6z2BdODn
qN0nhkqdebZhHgZopA4xgbBQx/C+pJDdNl+tQV5dIV9bjkOTKA4Yhw==", "collection"=>{"default_orientation"=>"ltr", "user_download"=>"
0", "alphabetize_works"=>"1", "hide_completed"=>"1", "messageboards_enabled"=>"0", "supports_document_sets"=>"1", "facets_
enabled"=>"0", "enable_spellcheck"=>"0", "voice_recognition"=>"0"}, "commit"=>"Save Changes", "id"=>"virginia-untold-commo
nwealth-causes"}
I, [2024-09-19T18:41:33.175855 #2941536]  INFO -- : Completed 500  in 1334ms (ActiveRecord: 307.7ms | Allocations: 815091)

I, [2024-09-19T18:41:33.175855 #2941536]  INFO -- : Completed 500  in 1334ms (ActiveRecord: 307.7ms | Allocations: 815091)
F, [2024-09-19T18:41:33.181145 #2941536] FATAL -- :   
ActiveRecord::RecordInvalid (Validation failed: Name has already been taken):

app/models/collection.rb:178:in `enable_messageboards'
app/controllers/collection_controller.rb:475:in `update'
app/controllers/application_controller.rb:64:in `switch_locale'
benwbrum commented 1 month ago

Researching more, it turns out that there was a Thredded::MessageboardGroup with the same title as the colleciton, probably created when someone enabled forums.

We need to make sure that either,