Tutor Richie error on sync

I’m just install tutor with command tutor local quickstart and add Richie plugin. New courses don’t showed in Richie, than I’m trying to reinitialize and get error.
ERROR 8 [richie.sync] [user None] [ip None] sync.py:67 - Could not synchronize course course-v1:ACI+Test_C+2021_12 with Richie. Response: {"resource_link":["Unknown course: TEST_C."]}

+1, I’m getting the same issue on my end:

cms_1 | 2021-12-15 13:01:38,256 ERROR 8 [richie.sync] [user 6] [ip 72.218.28.34] sync.py:67 - Could not synchronize course course-v1:Edunomic+CS101+2014_T1 with Richie. Response: {"resource_link":["Unknown course: CS101."]}

I’m troubleshooting and will report back if I find anything but it’s a bit of a labyrinth finding issues in Richie!

I tried running tutor local run richie ./sandbox/manage.py richie_init (only because it was under the header of ‘courses’ and these entries in the logs caught my eye:

richie_1            | [pid: 7|app: 0|req: 163/904] 172.18.0.16 () {56 vars in 2200 bytes} [Wed Dec 15 13:53:52 2021] GET /en/courses/?limit=21&offset=0&structure => generated 45995 bytes in 190 msecs (HTTP/1.0 200) 11 headers in 531 bytes (1 switches on core 0)
richie_1            | Bad Request: /api/v1.0/course-runs-sync/
richie_1            | [pid: 11|app: 0|req: 158/905] 172.18.0.14 () {38 vars in 578 bytes} [Wed Dec 15 14:01:37 2021] POST /api/v1.0/course-runs-sync/ => generated 44 bytes in 12 msecs (HTTP/1.1 400) 10 headers in 386 bytes (1 switches on core 0)
richie_1            | Bad Request: /api/v1.0/course-runs-sync/

Not sure if this is relevant but I’m assuming so for now.

Further updates. Using the example python code at Synchronizing course runs between Richie and OpenEdX · Richie I tried to run a manual sync using the secret from tutor.py:

Python 3.7.12 (default, Oct 22 2021, 17:50:30)
[Clang 13.0.0 (clang-1300.0.29.3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import hashlib
>>> import hmac
>>> import json
>>> import requests
>>> data = {
    "resource_link": "https://edunomic.academy/courses/course-v1:Edunomic+BC101+2021_Q4/course",
    "languages": ["en"]
}
>>> signature = hmac.new(
... "SECRET_KEY_GOES_HERE".encode("utf-8"),
... msg=json.dumps(data).encode("utf-8"),
... digestmod=hashlib.sha256,
... ).hexdigest()
>>> response = requests.post(
... "https://courses.edunomic.academy/api/v1.0/course-runs-sync/",
... json=data,
... headers={"Authorization": "SIG-HMAC-SHA256 {:s}".format(signature)},
... )

The result was the same as what we’re seeing in the logs:

>>> print(response)
<Response [400]>
>>> print(response.content)
b'{"resource_link":["Unknown course: BC101."]}'

Sadly not a solution but at least it’s manually testable and reproducible. I’m assuming the Course needs to be there before Course Runs can be synced, however:

  1. No course sync took place
  2. There is no “Create Course” option in the CMS wizard
  3. The docs make no mention of this

Continuing conversation at: Error synchronizing Richie <-> Tutor with the tutor-richie plugin · Issue #1544 · openfun/richie · GitHub

SOLVED UPDATE:

See the issue submitted to the richie project: Error synchronizing Richie <-> Tutor with the tutor-richie plugin · Issue #1544 · openfun/richie · GitHub

The solution is indeed that the course needs to exist on the Richie side before you can sync. To create a course, you must:

  1. Create an organization
  2. Go to the organization page
  3. Click ‘Create’ in the top right bar (CMS bar)
  4. Select Create Course

After that, new course runs will sync.