overhangio / tutor

The Docker-based Open edX distribution designed for peace of mind
https://docs.tutor.overhang.io/
GNU Affero General Public License v3.0
922 stars 440 forks source link

HiddenDescriptorWithMixins when accessing demo course #141

Closed JeffKatzy closed 5 years ago

JeffKatzy commented 5 years ago

Steps to reproduce

make lms python ./manage lms runserver 0.0.0.0:8000

make demo-course

Unexpected behavior

I am running into this error when trying to update the theme for the edx course page. If there's an easier way to develop a theme for a course, that works for me.

After running make demo-course, the demo course is displayed. But whenever visiting the demo course at http://0.0.0.0:8000/courses/course-v1:edX+DemoX+Demo_Course/about, get the following error:

File "/openedx/edx-platform/common/djangoapps/util/cache.py", line 76, in wrapper
    response = view_func(request, *args, **kwargs)
  File "/openedx/edx-platform/lms/djangoapps/courseware/views/views.py", line 761, in course_about
    course = get_course_with_access(request.user, permission, course_key)
  File "/openedx/edx-platform/lms/djangoapps/courseware/courses.py", line 98, in get_course_with_access
    check_course_access(course, user, action, check_if_enrolled, check_survey_complete)
  File "/openedx/edx-platform/lms/djangoapps/courseware/courses.py", line 130, in check_course_access
    if has_access(user, 'staff', course.id):
AttributeError: 'HiddenDescriptorWithMixins' object has no attribute 'id'

Seems like a HiddenDescriptorWithMixins object is created when trying to access the course. Strangely, if I run make run, I can access the course and the error does not appear.

@natea, I saw that you also ran into a HiddenDescriptorWithMixins error, related to the edx demo course. Were you able to make any progress on this?

Make info

/Library/Developer/CommandLineTools/usr/bin/make -s -C ../.. info
Darwin Jeffreys-MacBook-Air.local 18.2.0 Darwin Kernel Version 18.2.0: Mon Nov 12 20:24:46 PST 2018; root:xnu-4903.231.4~2/RELEASE_X86_64 x86_64
-------------------------
39e2c92374994229cec7fd3762e12901277b6e39
-------------------------
Client: Docker Engine - Community
 Version:           18.09.1
 API version:       1.39
 Go version:        go1.10.6
 Git commit:        4c52b90
 Built:             Wed Jan  9 19:33:12 2019
 OS/Arch:           darwin/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          18.09.1
  API version:      1.39 (minimum version 1.12)
  Go version:       go1.10.6
  Git commit:       4c52b90
  Built:            Wed Jan  9 19:41:49 2019
  OS/Arch:          linux/amd64
  Experimental:     false
-------------------------
docker-compose version 1.23.2, build 1110ad01
-------------------------
/Users/jeff/Documents/jigsaw/software/edx-software/downloaded-edx/edx-platform
tutor.development
regisb commented 5 years ago

@JeffKatzy Thanks for your thorough investigation! One thing is not quite clear. Do you get a 500 error when you visit http://0.0.0.0:8000/courses/course-v1:edX+DemoX+Demo_Course/about or is the about page correctly displayed?

It is very tempting to tag this issue as an upstream bug. Do you, by any chance, have a local devstack where you could compare the behaviour in the same conditions?

JeffKatzy commented 5 years ago

Hi Regis,

Yes, I get an error when visiting the about page.

Currently, I am thinking that maybe it does have to do with Open Edx pip package not being installed correctly. When I run pip install -e ., it breaks when installing the openedx package.

obtaining file:///openedx/edx-platform
Collecting setuptools (from Open-edX===0.10)
  Downloading https://files.pythonhosted.org/packages/bf/ae/a23db1762646069742cc21393833577d3fa438eecaa59d11fb04fa57fcd5/setuptools-40.7.1-py2.py3-none-any.whl (574kB)

Installing collected packages: setuptools, Open-edX
  Running setup.py develop for Open-edX
    Complete output from command /usr/bin/python -c "import setuptools, tokenize;__file__='/openedx/edx-platform/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" develop --no-deps --user --prefix=:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/openedx/edx-platform/setup.py", line 93, in <module>
        "password_policy = openedx.core.djangoapps.password_policy.apps:PasswordPolicyConfig",
      File "/openedx/.local/lib/python2.7/site-packages/setuptools/__init__.py", line 144, in setup
        _install_setup_requires(attrs)
      File "/openedx/.local/lib/python2.7/site-packages/setuptools/__init__.py", line 137, in _install_setup_requires
        dist.parse_config_files(ignore_option_errors=True)
      File "/openedx/.local/lib/python2.7/site-packages/setuptools/dist.py", line 702, in parse_config_files
        self._parse_config_files(filenames=filenames)
      File "/openedx/.local/lib/python2.7/site-packages/setuptools/dist.py", line 599, in _parse_config_files
        (parser.read_file if six.PY3 else parser.readfp)(reader)
      File "/usr/lib/python2.7/ConfigParser.py", line 324, in readfp
        self._read(fp, filename)
      File "/usr/lib/python2.7/ConfigParser.py", line 479, in _read
        line = fp.readline()
      File "/usr/lib/python2.7/encodings/ascii.py", line 26, in decode
        return codecs.ascii_decode(input, self.errors)[0]
    UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 876: ordinal not in range(128)

    ----------------------------------------
Command "/usr/bin/python -c "import setuptools, tokenize;__file__='/openedx/edx-platform/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" develop --no-deps --user --prefix=" failed with error code 1 in /openedx/edx-platform/

Update: So, I believe I was able to get past this on the host by running sudo python setup.py install instead of pip install. However, I am unsure of how to do this on a docker container because I do not have access to sudo. I'm now going to try to install sudo.

"Do you, by any chance, have a local devstack where you could compare the behaviour in the same conditions?"

Not sure, what this would entail. Isn't that what I working with when I run make lms? (I'm a developer/teacher by trade, only about a month into the devops, docker world - but happy put up a local devstack if it's not too difficult. Today I did point my docker instance to fresh clone of edx, and ran into the same essentially the same error (see more below).

JeffKatzy commented 5 years ago

Update: Ok so was able to run python setup.py install, and the error message changed. Now when I go to the about page I get an error at essentially the same place if has_access(user, 'staff', course.id):, but now the error is Connection refused to mongo.

2019-01-31 21:11:27,994 INFO 143 [tracking] logger.py:50 - {"username": "", "event_type": "/courses/course-v1:JigsawLabs+123+Spring/about", "ip": "172.19.0.1", "agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36", "host": "4f6ee2d78b05", "referer": "http://0.0.0.0:8000/", "accept_language": "en-US,en;q=0.9", "event": "{\"POST\": {}, \"GET\": {}}", "event_source": "server", "context": {"course_user_tags": {}, "user_id": null, "org_id": "JigsawLabs", "course_id": "course-v1:JigsawLabs+123+Spring", "path": "/courses/course-v1:JigsawLabs+123+Spring/about"}, "time": "2019-01-31T21:11:27.989560+00:00", "page": null}
2019-01-31 21:11:28,047 ERROR 143 [root] signals.py:17 - Uncaught exception from None
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/exception.py", line 41, in inner
    response = get_response(request)
  File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 249, in _legacy_get_response
    response = self._get_response(request)
  File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 187, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 185, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py", line 185, in inner
    return func(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py", line 149, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "/openedx/edx-platform/common/djangoapps/util/views.py", line 50, in inner
    response = view_func(request, *args, **kwargs)
  File "/openedx/edx-platform/common/djangoapps/util/cache.py", line 76, in wrapper
    response = view_func(request, *args, **kwargs)
  File "/openedx/edx-platform/lms/djangoapps/courseware/views/views.py", line 759, in course_about
    with modulestore().bulk_operations(course_key):
  File "/openedx/edx-platform/common/lib/xmodule/xmodule/modulestore/django.py", line 321, in modulestore
    settings.MODULESTORE['default'].get('OPTIONS', {})
  File "/openedx/edx-platform/common/lib/xmodule/xmodule/modulestore/django.py", line 303, in create_modulestore_instance
    **_options
  File "/openedx/edx-platform/common/lib/xmodule/xmodule/modulestore/mixed.py", line 176, in __init__
    signal_handler=signal_handler,
  File "/openedx/edx-platform/common/lib/xmodule/xmodule/modulestore/django.py", line 303, in create_modulestore_instance
    **_options
  File "/openedx/edx-platform/common/lib/xmodule/xmodule/modulestore/split_mongo/split.py", line 707, in __init__
    self.db_connection = MongoConnection(**doc_store_config)
  File "/openedx/edx-platform/common/lib/xmodule/xmodule/modulestore/split_mongo/mongo_connection.py", line 300, in __init__
    retry_wait_time=retry_wait_time, **kwargs
  File "/openedx/edx-platform/common/lib/xmodule/xmodule/mongo_utils.py", line 50, in connect_to_mongodb
    **kwargs
  File "/usr/local/lib/python2.7/dist-packages/pymongo/mongo_client.py", line 425, in __init__
    raise ConnectionFailure(str(e))
ConnectionFailure: [Errno 111] Connection refused
Internal Server Error: /courses/course-v1:JigsawLabs+123+Spring/about

Currently referencing this stackoverflow post.

Tried to translate changes in the stackoverflow post for the tutor setup, so:

Also got this suggestion via openedx slack, which I plan to explore

It's possible the setup.py for the XBlocks/XModules hasn't been installed. HiddenDescriptor is a fallback when we can't find the appropriate XBlock or XModule to render the content. running "paver lms" should do all the installs needed in the process of starting it up

regisb commented 5 years ago

Hi @JeffKatzy, I can't seem to reproduce your issue. Did you customize your platform in any way? For instance, did you mount a local edx-platform repo by setting one of the EDX_PLATFORM_PATH variable? Did you re-build the openedx docker image?

JeffKatzy commented 5 years ago
  1. For instance, did you mount a local edx-platform repo by setting one of the EDX_PLATFORM_PATH variable?

Yes, I set the EDX_PLATFORM_PATH variable to point to an un-updated local repo. Can I leave this out as I am only working with theming?

  1. Did you re-build the openedx docker image? Maybe. When setting up theming, I referenced this issue.

https://github.com/regisb/tutor/issues/88 And so ran:

cd build make build-openedx

To make sure this image is not being used in development, is it enough for me to run docker system prune?

Thanks for all of the help on this.

regisb commented 5 years ago

Yes, I set the EDX_PLATFORM_PATH variable to point to an un-updated local repo.

I believe all your issues are caused by the fact that you are using a custom repo. Please go to your edx-platform repo and run git log -1. What does it show?

Can I leave this out as I am only working with theming?

Yes, probably. You can follow the instructions from http://docs.tutor.overhang.io/en/latest/dev.html#customised-themes

JeffKatzy commented 5 years ago
commit 58d2ac8c92c4cffe3d8db180b45bdcfba7040a7f (grafted, HEAD, tag: open-release/hawthorn.2)
Author: Farhanah Sheets <fsheets@edx.org>
Date:   Mon Sep 10 20:21:56 2018 -0400

    Edit test value to be valid URL format

    (cherry picked from commit 5c3c0f0fcb742fbde6eff3a3ce98c7ee96d0edf6)
JeffKatzy commented 5 years ago

Ok, I stopped using the EDX_PLATFORM_PATH variable. I'm still able to apply custom themes. That fixed it. Exhale. Thanks again.

regisb commented 5 years ago

Awesome!