Scifabric / pybossa

PYBOSSA is the ultimate crowdsourcing framework (aka microtasking) to analyze or enrich data that can't be processed by machines alone.
http://pybossa.com
GNU Affero General Public License v3.0
742 stars 265 forks source link

"Reserved keys in payload" when updating project #1869

Closed peterdekker closed 6 years ago

peterdekker commented 6 years ago

I created a PyBOSSA project, which worked before. However, now when I try to update the project, I get the following error:

{u'status': u'failed', u'target': u'project', u'exception_msg': u'Reserved keys in payload', u'status_code': 400, u'exception_cls': u'BadRequest', u'action': u'PUT'}
Project not found! The project: opentaal is missing. Use the flag --all=1 to search in all the server

I debugged the error, and found out the key secret_key in data caused the error. However, I never used secret_key in my project.

I also extracted the data object:

{u\'info\': {u\'task_presenter\': u\'<div class="row">\\n    <!-- Success and Error Messages for the user --> \\n    <div class="col-md-6 col-md-offset-2" style="height:50px">\\n        <div id="success" class="alert alert-success" style="display:none;">\\n            <a class="close">\\xd7</a>\\n            <strong>Bedankt!</strong> Je antwoord is opgeslagen.\\n        </div>\\n        <div id="success-details" class="alert alert-success" style="display:none;">\\n            <a class="close">\\xd7</a>\\n            <strong>Bedankt!</strong> Je gegevens zijn opgeslagen.\\n        </div>\\n        <div id="loading" class="alert alert-info" style="display:none;">\\n            <a class="close">\\xd7</a>\\n            Volgende taak aan het laden...\\n        </div>\\n        <div id="taskcompleted" class="alert alert-info" style="display:none;">\\n            <strong>De taak is afgerond!</strong> Bedankt!\\n        </div>\\n        <div id="finish" class="alert alert-success" style="display:none;">\\n            <strong>Gefeliciteerd!</strong> Je hebt deelgenomen aan alle beschikbare taken.\\n            <br/>\\n            <div class="alert-actions">\\n                <a class="btn small" href="/">Ga terug</a>\\n                <a class="btn small" href="/app">of bekijk alle projecten</a>\\n            </div>\\n        </div>\\n        <div id="error" class="alert alert-danger" style="display:none;">\\n            <a class="close">\\xd7</a>\\n            <strong>Fout!</strong> Er ging iets mis, neem contact op met beheerders van deze website.\\n        </div>\\n    </div> <!-- End Success and Error Messages for the user -->\\n</div> <!-- End of Row -->\\n\\n<div class="row skeleton-userdetails"> <!-- Start Skeleton Row-->\\n    <div class="col-md-6 "><!-- Start of Question and Submission DIV (column) -->\\n        <h3 id="headerAge">Leeftijd:</h3> <!-- The word will be loaded here -->\\n        <form class="form-inline">\\n                <textarea id="age" rows="1" style="width:100%;"></textarea>\\n            </form>\\n        <br><br>\\n        <h3 id="headerGender">Geslacht:</h3> <!-- The word will be loaded here -->\\n        <form class="form-inline">\\n                <textarea id="gender" rows="1" style="width:100%;"></textarea>\\n            </form>\\n        <br><br>\\n        <h3 id="headerLocation">Woonplaats:</h3> <!-- The word will be loaded here -->\\n        <form class="form-inline">\\n                <textarea id="location" rows="1" style="width:100%;"></textarea>\\n            </form>\\n        <br><br>\\n        <div id="answer"> <!-- Start DIV for the submission buttons -->\\n            <button class="btn btn-submit btn-primary btn-sm btn-submit-userdetails"><i class="fa fa-thumbs-o-up"></i>Verzend!</button>\\n        </div><!-- End of DIV for the submission buttons -->\\n    </div><!-- End of Question and Submission DIV (column) -->\\n</div><!-- End of Skeleton Row -->\\n\\n<div class="row skeleton-finish"> <!-- Start Skeleton Row-->\\n    <div class="col-md-6 "><!-- Start of Question and Submission DIV (column) -->\\n    \\t<h1>Dankjewel, je hebt alle taken uitgevoerd!</h1>\\n        <h3>Jouw ingevulde gegevens:</h3>\\n        Leeftijd: <span id="labelAge"></span><br>\\n        Geslacht: <span id="labelGender"></span><br>\\n        Woonplaats: <span id="labelLocation"></span><br>\\n        <h3>Volgens ons ben je:</h3>\\n        Leeftijd: <span id="labelAgePrediction"></span><br>\\n        Geslacht: <span id="labelGenderPrediction"></span><br>\\n        Woonplaats: <span id="labelLocationPrediction"></span><br>\\n    </div><!-- End of Question and Submission DIV (column) -->\\n</div><!-- End of Skeleton Row -->\\n\\n<!--\\n    Task DOM for showing the data to the user\\n    It uses the class="skeleton" to identify the elements that belong to the\\n    task.\\n-->\\n<div class="row skeleton-task"> <!-- Start Skeleton Row-->\\n    <div class="col-md-6 "><!-- Start of Question and Submission DIV (column) -->\\n        <h3 id="question">Geef een synoniem voor het volgende woord:</h1> <!-- The question will be loaded here -->\\n        <h1 id="word">(voorbeeldwoord)</h3> <!-- The word will be loaded here -->\\n        <form class="form-inline">\\n                <textarea id="text" rows="10" style="width:100%;"></textarea>\\n            </form>\\n        <br><br>\\n        <div id="answer"> <!-- Start DIV for the submission buttons -->\\n            <button class="btn btn-submit btn-primary btn-sm btn-submit-task"><i class="fa fa-thumbs-o-up"></i>Verstuur synoniem!</button>\\n            <!-- If the user clicks this button, the saved answer will be value="NotKnown"-->\\n            <button class="btn btn-dontknow" value=\\\'NotKnown\\\'><i class="fa fa-question-circle"></i>Weet ik niet</button>\\n        </div><!-- End of DIV for the submission buttons -->\\n        <!-- Feedback items for the user -->\\n        <p>Je werkt nu aan taak: <span id="task-id" class="label label-warning">#</span></p>\\n        <p>Afgeronde taken: <span id="done" class="label label-info"></span> van\\n        <!-- Progress bar for the user -->\\n        <span id="total" class="label label-info"></span></p>\\n        <div class="progress progress-striped">\\n            <div id="progress" rel="tooltip" title="#" class="progress-bar" style="width: 0%;"  role="progressbar"></div>\\n        </div>\\n        <!-- \\n            This application uses Disqus to allow users to provide some feedback.\\n            The next section includes a button that when a user clicks on it will\\n            load the comments, if any, for the given task\\n        -->\\n        <div id="disqus_show_btn" style="margin-top:5px;">\\n            <button class="btn btn-primary btn-large btn-disqus" onclick="loadDisqus()"><i class="fa fa-comments"></i> <span id="i18n_show_comments">Show comments</span></button>\\n            <button class="btn btn-large btn-disqus" onclick="loadDisqus()" style="display:none"><i class="fa fa-comments"></i> <span id="i18n_hide_comments">Hide comments</span></button>\\n        </div><!-- End of Disqus Button section -->\\n        <!-- Disqus thread for the given task -->\\n        <div id="disqus_thread" style="margin-top:5px;display:none"></div>\\n    </div><!-- End of Question and Submission DIV (column) -->\\n</div><!-- End of Skeleton Row -->\\n\\n<script type="text/javascript">\\n\\t// TODO: When finishing contribution, let Python script retrieve user details from database, instead of local storage.\\n    /* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */\\n\\n    /* * * DON\\\'T EDIT BELOW THIS LINE * * */\\n    function loadDisqus() {\\n    $("#disqus_thread").toggle();\\n    $(".btn-disqus").toggle();\\n    var disqus_shortname = \\\'pybossa\\\'; // required: replace example with your forum shortname\\n    //var disqus_identifier = taskId;\\n    var disqus_developer = 1;\\n\\n    (function() {\\n        var dsq = document.createElement(\\\'script\\\'); dsq.type = \\\'text/javascript\\\'; dsq.async = true;\\n        dsq.src = \\\'http://\\\' + disqus_shortname + \\\'.disqus.com/embed.js\\\';\\n        (document.getElementsByTagName(\\\'head\\\')[0] || document.getElementsByTagName(\\\'body\\\')[0]).appendChild(dsq);\\n    })();\\n    }\\n\\n</script>\\n<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments (powered by Disqus).</a></noscript>\\n\\n<script>\\n\\n\\n// Update userLocale with server side information\\n $(document).ready(function(){\\n     userLocale = document.getElementById(\\\'PYBOSSA_USER_LOCALE\\\').textContent.trim();\\n\\n});\\n\\n\\n\\nfunction loadUserProgress() {\\n    pybossa.userProgress(\\\'opentaal\\\').done(function(data){\\n        var pct = Math.round((data.done*100)/data.total);\\n        $("#progress").css("width", pct.toString() +"%");\\n        $("#progress").attr("title", pct.toString() + "% completed!");\\n        $("#progress").tooltip({\\\'placement\\\': \\\'left\\\'}); \\n        $("#total").text(data.total);\\n        $("#done").text(data.done);\\n    });\\n}\\n\\nfunction showDetailsForm(task, deferred) {\\n\\t$(".skeleton-task").hide();\\n\\t$(".skeleton-task").finish();\\n\\t$(".skeleton-userdetails").show();\\n\\tdetails_shown = true;\\n\\t// Submit button\\n    $(".btn-submit-userdetails").off(\\\'click\\\').on(\\\'click\\\', function(){\\n        var user_details = {"age": $("textarea#age").val(), "gender": $("textarea#gender").val(), "location": $("textarea#location").val()};\\n        localStorage.user_details = JSON.stringify(user_details);\\n        pybossa.saveTask(task.id, user_details).done(function(data){\\n            deferred.resolve();\\n            $("#success-details").fadeIn();\\n            setTimeout(function() { $("#success-details").fadeOut() }, 2000);\\n        })\\n    });\\n}\\n\\nfunction showTask(task, deferred) {\\n\\tconsole.log(task);\\n\\t$(".skeleton-userdetails").hide();\\n\\t$(".skeleton-finish").hide();\\n\\t$(".skeleton-task").show();\\n    loadUserProgress();\\n    $("textarea#text").val(\\\'\\\');\\n    $("#question").html(task.info.question);\\n    $("#word").html(task.info.word);\\n    $("#task-id").html(task.id);\\n    // Submit button\\n    $(".btn-submit-task").off(\\\'click\\\').on(\\\'click\\\', function(){\\n        var answer = $("textarea#text").val();\\n        pybossa.saveTask(task.id, answer).done(function(data){\\n            deferred.resolve();\\n            $("#success").fadeIn();\\n            setTimeout(function() { $("#success").fadeOut() }, 2000);\\n        })\\n    });\\n    \\n    // Do not know button\\n    $(".btn-dontknow").off(\\\'click\\\').on(\\\'click\\\', function(){\\n        var answer = "";\\n        pybossa.saveTask(task.id, answer).done(function(data){\\n            deferred.resolve();\\n            $("#success").fadeIn();\\n            setTimeout(function() { $("#success").fadeOut() }, 2000);\\n        })\\n    });\\n    $("#loading").hide();\\n}\\n\\nfunction finish() {\\n\\t$(".skeleton-task").hide();\\n\\t$(".skeleton-userdetails").hide();\\n\\t$("#loading").hide();\\n\\t$(".skeleton-finish").show();\\n    //$("#finish").fadeIn(500);\\n    \\n    // Load fields with user details from local storage\\n    var user_details = {};\\n    if ("user_details" in localStorage) {\\n    \\tJSON.parse(localStorage.user_details);\\n    }\\n    $("#labelAge").html(user_details.age);\\n    $("#labelGender").html(user_details.gender);\\n    $("#labelLocation").html(user_details.location);\\n    \\n    $.ajax({\\n         type:\\\'get\\\',\\n         url:\\\'/computation/getcomputation\\\',\\n         cache:false,\\n         async:\\\'asynchronous\\\',\\n         dataType:\\\'json\\\',\\n         success: function(data) {\\n           console.log(data)\\n           $("#labelAgePrediction").html(data.age);\\n           $("#labelGenderPrediction").html(data.gender);\\n           $("#labelLocationPrediction").html(data.location);\\n         },\\n         error: function(request, status, error) {\\n           console.log("Error: " + error + " "+JSON.stringify(request))\\n         }\\n      });\\n}\\n\\npybossa.presentTask(function(task, deferred) {\\n    if ( !$.isEmptyObject(task) ) {\\n    \\tif (task.info.type == "userdetails") {\\n    \\t\\t// Show page to give personal details\\n    \\t\\tshowDetailsForm(task, deferred);\\n    \\t}\\n    \\telse {\\n    \\t\\t// Show task\\n    \\t\\tshowTask(task, deferred);\\n    \\t}\\n    }\\n    else {\\n    \\tfinish();\\n    }\\n});\\n\\npybossa.run(\\\'opentaal\\\');\\n</script>\\n\', u\'results\': u\'<!DOCTYPE html>\\n<html lang="en">\\n    <head>\\n        <meta http-equiv="content-type" content="text/html; charset=utf-8" />\\n        <meta name="description" content="Flickr Person Finder Results page">\\n    \\n        <title>Results for Flickr Person Finder</title>\\n    <!-- Le styles -->\\n    <link href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css" rel="stylesheet">\\n\\n    <!-- Le javascript-->\\n    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>\\n    <script src="http://d3js.org/d3.v2.js"></script>\\n    </head>\\n    <body>\\n        <div class="container" style="padding-top: 20px">\\n            <div class="row">\\n                <div class="span10 offset1 well" style="text-align:center">\\n                    <h2>Distribution of votes for <small>Flickr Person Finder</small></h2>\\n                </div>\\n            </div>\\n            <div class="row">\\n                <div id="arcs" class="span7 offset2"></div>\\n                <div class="span3" style="text-align:center">\\n                    <button class="btn btn-large btn-success"  onclick="create_arcs_for()">\\n                        Check task &raquo;\\n                    </button>\\n                    <input class="span1" type="text" style="height:22px" name="taskId" id="taskId"/>\\n                    <h3>Or</h3>\\n                    <button id="next" class="btn btn-large btn-primary" onclick="create_arcs()">\\n                    Check task\\n                    </button>\\n                </div>\\n            </div>\\n            <div class="row">\\n                <div id="img" class="span8 offset2" style="margin-top:-120px; text-align:center;">\\n                    <ul class="thumbnails">\\n                        <li class="span6">\\n                            <img id="flickr" src="#" class="thumbnail">\\n                        </li>\\n                </div>\\n            </div>\\n            <div class="row">\\n                <div class="span8 offset2">\\n                </div>\\n            </div>\\n        </div>\\n    <!-- Le results -->\\n    <script src="results.js"></script>\\n    <footer style="text-align:center">\\n    Powered by <a href="http://pybossa.com">PyBossa<a/>\\n    </footer>\\n    </body>\\n</html>\\n\', u\'tutorial\': u\'<div class="row">\\n    <div class="col-md-12">\\n        <div id="modal" class="modal hide fade">\\n            <div class="modal-header">\\n                <h3>Flickr Person Finder tutorial</h3>\\n            </div>\\n            <div id="0" class="modal-body" style="display:none">\\n                <p><strong>Hi!</strong> This is a <strong>demo project</strong> that shows how you can do pattern recognition on pictures or images using the PyBossa framework in Crowdcrafting.org.\\n               </p> \\n            </div>\\n            <div id="1" class="modal-body" style="display:none">\\n                <p>The application is really simple. It loads a photo from <a href="http://flickr.com">Flickr</a> and asks you this question: <strong>Do you see a human in this photo?</strong></p>\\n                <img src="http://farm7.staticflickr.com/6109/6286728068_2f3c6912b8_q.jpg" class="img-thumbnail"/>\\n                <p>You will have 3 possible answers:\\n                <ul>\\n                    <li>Yes,</li>\\n                    <li>No, and</li>\\n                    <li>I don\\\'t know</li>\\n                </ul>\\n                </p>\\n                <p>\\n                </p>\\n                <p>All you have to do is to click in one of the three possible answers and you will be done. This demo project could be adapted for more complex pattern recognition problems.</p>\\n            </div>\\n            <div class="modal-footer">\\n                <a id="prevBtn" href="#" onclick="showStep(\\\'prev\\\')" class="btn">Previous</a>\\n                <a id="nextBtn" href="#" onclick="showStep(\\\'next\\\')" class="btn btn-success">Next</a>\\n                <a id="startContrib" href="../flickrperson/newtask" class="btn btn-primary" style="display:none"><i class="fa fa-thumbs-o-up"></i> Try the demo!</a>\\n            </div>\\n        </div>\\n    </div>\\n</div>\\n<script>\\n    var step = -1;\\n    function showStep(action) {\\n        $("#" + step).hide();\\n        if (action == \\\'next\\\') {\\n            step = step + 1;\\n        }\\n        if (action == \\\'prev\\\') {\\n            step = step - 1;\\n        }\\n        if (step == 0) {\\n            $("#prevBtn").hide();\\n        }\\n        else {\\n            $("#prevBtn").show();\\n        }\\n\\n        if (step == 1 ) {\\n            $("#nextBtn").hide();\\n            $("#startContrib").show();\\n        }\\n        $("#" + step).show();\\n    }\\n\\n    showStep(\\\'next\\\');\\n    $("#modal").modal(\\\'show\\\');\\n</script>\\n\'}, u\'category_id\': 1, u\'description\': u\'Geef aan of een woord van OpenTaal bekend is of niet\', u\'short_name\': u\'opentaal\', u\'owners_ids\': [1], u\'webhook\': None, u\'zip_download\': True, u\'links\': [u"<link rel=\'category\' title=\'category\' href=\'http://localhost:5000/api/category/1\'/>"], u\'featured\': False, u\'link\': u"<link rel=\'self\' title=\'project\' href=\'http://localhost:5000/api/project/10\'/>", u\'allow_anonymous_contributors\': True, u\'secret_key\': u\'156a4bdc-debc-4343-98ab-05f69be85738\', u\'owner_id\': 1, u\'long_description\': u\'OpenTaal is een **demo-project** om de mogelijkheden van PyBossa voor het INT\\nte tonen. Gebruikers krijgen woorden uit de OpenTaal-woordenlijst te zien en\\ngeven aan of ze dit woord kennen of niet.\\n\\n\', u\'name\': u\'OpenTaal\'}', u'status_code': 400, u'exception_cls': u'BadRequest', u'action': u'PUT'}

Is this a bug, or am I doing something wrong?

teleyinex commented 6 years ago

Are you using an old version of enki and/or pbclient? Because, maybe you have an old version and when you grab the project via those, the secret key is not removed when updating it. Can you try with a new version of pbclient?

peterdekker commented 6 years ago

Thanks for the suggestion! I updated enki, pbs and pbclient using pip. Yet, the problem still occurs unfortunately.

teleyinex commented 6 years ago

Are you using a virtualenv? If you are, try to open the file init.py of pbclient package and check if your installation has this line: https://github.com/Scifabric/pybossa-client/blob/master/pbclient/__init__.py#L102

As you will see, in our code the secret_key is listed as a reserved word, so maybe you have an old version.

teleyinex commented 6 years ago

Or we haven't pushed the latest version to pypi :D

peterdekker commented 6 years ago

I installed the wrong packages via pip: it had to be pybossa-client and pybossa-pbs instead of pbclient and pbs. Now the problem has been solved! Thanks.

However, I think the dependencies of the packages have to be updated:

pybossa-pbs 2.4.7 has requirement pybossa-client<1.2.2,>=1.2.1, but you'll have pybossa-client 2.0.1 which is incompatible.
enki 1.1.1 has requirement pybossa-client<1.1.2,>=1.1.1, but you'll have pybossa-client 2.0.1 which is incompatible.
therealmarv commented 6 years ago

we will look into the dependencies! thx.