crowdAI / crowdai

Fighting for Open Science with Open Data
https://www.crowdai.org
GNU Affero General Public License v3.0
149 stars 32 forks source link

error on `meta` update #814

Open spMohanty opened 6 years ago

spMohanty commented 6 years ago

I get this error when I am trying to do an update for meta. unable to convert unpermitted parameters to hash

Mostly happening because of this : https://github.com/crowdAI/crowdai/blob/master/app/controllers/api/external_graders_controller.rb#L119 Reference : https://stackoverflow.com/questions/46029084/rails-unable-to-convert-unpermitted-parameters-to-hash?rq=1

To replicate this, you can first create a new submission using an arbitrary meta param, which will work as expected. But then if you try to update the same submission again with the same or different meta then it throws the error above. This test replicates the error: https://github.com/crowdAI/crowdai_api/blob/master/tests/test_update_submission.py#L44

For now we can simply assume that we will always use meta_overwrite=True (https://github.com/crowdAI/crowdai/blob/master/app/controllers/api/external_graders_controller.rb#L108) until we find a better fix for the hash merges.

spMohanty commented 6 years ago

A really desperate fix for this issue is simply deploying this commit : https://github.com/crowdAI/crowdai/commit/648a844c3b85b9cdd223fd7b4399e3c365307f96 (It will need me to explicitly specify meta_overwrite on all update calls)

But in general we will have to solve this issue properly, as this is critical to all the challenges which use the meta params. And most of the challenges store challenge specific (and non -generalizable) params in the meta hash.

scarroll32 commented 6 years ago

To reproduce the issue:

  1. Data in the submission record
id                      | 7016
challenge_id            | 34
participant_id          | 7
score                   | 25
created_at              | 2018-05-27 16:14:29.05224
updated_at              | 2018-05-27 16:14:29.309171
description             |
score_secondary         | 2.66666666667
grading_message         | Test Message
grading_status_cd       | graded
description_markdown    |
vote_count              | 0
post_challenge          | f
api                     |
media_large             |
media_thumbnail         |
media_content_type      |
challenge_round_id      | 38
meta                    | {"file_key":"something0.27552942878"}
short_url               | d582989eac51
clef_method_description |
clef_retrieval_type     |
clef_run_type           |
clef_primary_run        | f
clef_other_info         |
clef_additional         |
online_submission       | f
  1. API call
PATCH path= "/api/external_graders/7016?meta%5Bfile_key%5D= something0.767241296528&score= 25&grading_message= Test+Message&score_secondary= 2.66666666667&grading_status= graded&api_key= [REDACTED]&challenge_client_name=test_challenge" 
  1. Error message
unable to convert unpermitted parameters to hash
  1. Expected behaviour

meta field should be updated to:

{"file_key":"something0.767241296528"}
spMohanty commented 6 years ago

At the moment, we want the meta to hold to a json object which can have arbitrary parameters. Ideally the update call should "merge" the json objects. But for not thats not possible, so from crowdai_api I am always checking the latest value of the json and sending the whole updated json object again.

scarroll32 commented 6 years ago

Agreement to:

Needs to support multi-level, arrays etc.