learn-ocaml icon indicating copy to clipboard operation
learn-ocaml copied to clipboard

Bug: Invalid_argument "Registration of teacher token not allowed"

Open EmileRolley opened this issue 4 years ago • 5 comments

Related project scope: grader

Bug description

When trying to grade an exercise from the demo-repository, an internal error is raised.

To Reproduce

Steps to reproduce the behavior:

  1. Checkout to the master branch.
  2. Compile the project:
make clean && make build && make opaminstall && eval $(opam env)
  1. Generate the application based on demo-repository:
learn-ocaml build --repo demo-repository
  1. Run the server:
learn-ocaml serve
  1. Click on Exercises > Demo of the exercise environment > Grade!
  2. See error:

Screenshot from 2021-07-16 19-12-52

Current configuration

  • OS: Pop!_OS 20.04 LTS
  • Browser: Brave Browser 91.1.26.74
  • Version: learn-ocaml v0.12

EmileRolley avatar Jul 16 '21 17:07 EmileRolley

Hi @EmileRolley, thanks for checking this!

Actually I cannot reproduce this error. Unless I do all steps you mentioned and:

  • stop the server with ^C,
  • remove the sync folder,
  • restart the server with learn-ocaml build --repo demo-repository serve
    (which creates a new valid initial token teacher, invalidating the former as the previous sync folder has been removed)
  • redo the grading while still be connected with the previous, now non-existing X-TOKEN.

erikmd avatar Jul 16 '21 21:07 erikmd

Hi @erikmd, you are welcome!

I was able to resolve this issue by logging out and creating a new token. But now I can't reproduce it anymore (even by doing the steps you mentioned)...

EmileRolley avatar Jul 17 '21 12:07 EmileRolley

Hi @EmileRolley, yes, that's what I was meaning to say: logging-out and using a (new) token adapted to the new server should solve the issue, and I'm not surprised that you weren't able to reproduce the issue a second time, because I guess the new token you had used in the end was not a X-… teacher token, consequently the following line was not triggered anymore:

https://github.com/ocaml-sf/learn-ocaml/blob/61941cd4bdaa114d170456914510fc6477d41f6d/src/state/learnocaml_store.ml#L340-L342

because in your situation (if I have guessed accurately), is_teacher token = false

So I guess the underlying issue (the fact that when we wipe out the database of a learn-ocaml instance, teachers which are currently logged-in with a now-removed teacher token get an error on Grade) is not a blocking issue… but it's true that

  1. it might be documented somewhere → maybe just by adding a remark in the error message? (and translate it to French) https://github.com/ocaml-sf/learn-ocaml/blob/61941cd4bdaa114d170456914510fc6477d41f6d/src/state/learnocaml_store.ml#L342 to

    Lwt.fail (Invalid_argument "Registration of teacher token forbidden. Logout and use a new teacher token?")
    
  2. the "converse" situation would need some investigation I guess:

    • when the database of a learn-ocaml instance has been wiped,
    • what happens to currently logged-in students that try to re-grade?
    • in particular if there is a secret needed by the learn-ocaml instance admin to prevent people to sign-up…

So I'd be happy to accept a PR for point 1. above, and maybe we could let this issue opened until @yurug and I get convinced that there's something to do (or not) for the point 2.

BTW just FTR, here is the procedure to update French translations:

  • for Emacs users on Debian/Ubuntu: sudo apt-get update && sudo apt-get install gettext-el (to be run only once)
  • make update-fr-translation (to be run anytime we want to extract the (new) occurrences of [%i"English messages"])
  • emacs translations/fr.po; select a line (↑/↓), type RET to edit a translation, then C-c C-c; C-h m to see other shortcuts.

erikmd avatar Jul 19 '21 19:07 erikmd

Ok, I see. I'll open a PR for the first point, but I don't really get when and where the translation is used..

EmileRolley avatar Jul 20 '21 09:07 EmileRolley

Sorry, I realize we can actually forget about the translation here: as the English message was not surrounded with [%i" ... "]. So that would just be a one-liner PR I guess :)

erikmd avatar Jul 20 '21 10:07 erikmd