learn-ocaml
learn-ocaml copied to clipboard
Bug: Invalid_argument "Registration of teacher token not allowed"
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:
- Checkout to the
masterbranch. - Compile the project:
make clean && make build && make opaminstall && eval $(opam env)
- Generate the application based on
demo-repository:
learn-ocaml build --repo demo-repository
- Run the server:
learn-ocaml serve
- Click on
Exercises > Demo of the exercise environment > Grade! - See error:

Current configuration
- OS:
Pop!_OS 20.04 LTS - Browser:
Brave Browser 91.1.26.74 - Version:
learn-ocaml v0.12
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
syncfolder, - restart the server with
learn-ocaml build --repo demo-repository serve
(which creates a new valid initial token teacher, invalidating the former as the previoussyncfolder has been removed) - redo the grading while still be connected with the previous, now non-existing X-TOKEN.
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)...
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
-
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?") -
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
secretneeded 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 (↑/↓), typeRETto edit a translation, thenC-c C-c;C-h mto see other shortcuts.
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..
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 :)