appsembler / figures

Reporting and data retrieval app for Open edX
MIT License
44 stars 37 forks source link

/figures/api/users/detail/?enrolled_in_course_id=course-v1:edX+DemoX+Demo_Course 404 #52

Open jerrybox opened 5 years ago

jerrybox commented 5 years ago

URL: http://192.168.56.10/figures/course/course-v1:edX+DemoX+Demo_Course

==> /edx/var/log/nginx/access.log <==
- - 127.0.0.1 - edx [15/Oct/2018:00:37:35 +0000]  "GET /xqueue/get_queuelen/?queue_name=certificates HTTP/1.1" 200 61 0.104 "-" "python-requests/2.3.0 CPython/2.7.12 Linux/4.4.0-31-generic"

==> /edx/var/log/lms/edx.log <==
Oct 15 00:37:39 vagrant [service_variant=lms][track.contexts][env:sandbox] WARNING [vagrant  9652] [contexts.py:31] - unable to parse course_id "detail/course-v1:edX+DemoX+Demo_Course"
Traceback (most recent call last):
 File "/edx/app/edxapp/edx-platform/common/djangoapps/track/contexts.py", line 25, in course_context_from_url
   course_id = SlashSeparatedCourseKey.from_deprecated_string(course_id_string)
 File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/opaque_keys/edx/locations.py", line 49, in from_deprecated_string
   return CourseLocator.from_string(serialized)
 File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/opaque_keys/__init__.py", line 197, in from_string
   return cls.deprecated_fallback._from_deprecated_string(serialized)
 File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/opaque_keys/edx/locator.py", line 379, in _from_deprecated_string
   raise InvalidKeyError(cls, serialized)
InvalidKeyError: <class 'opaque_keys.edx.locator.CourseLocator'>: detail/course-v1:edX+DemoX+Demo_Course

==> /edx/var/log/nginx/access.log <==
- - 192.168.56.1 - - [15/Oct/2018:00:37:40 +0000]  "GET /figures/api/courses/detail/course-v1:edX+DemoX+Demo_Course/ HTTP/1.1" 200 335 0.287 "http://192.168.56.10/figures/course/course-v1:edX+DemoX+Demo_Course" "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36"
- - 127.0.0.1 - edx [15/Oct/2018:00:37:40 +0000]  "GET /xqueue/get_queuelen/?queue_name=certificates HTTP/1.1" 200 61 0.119 "-" "python-requests/2.3.0 CPython/2.7.12 Linux/4.4.0-31-generic"

==> /edx/var/log/lms/edx.log <==
Oct 15 00:37:40 vagrant [service_variant=lms][openedx.core.djangoapps.content.block_structure.store][env:sandbox] INFO [vagrant  9658] [store.py:176] - BlockStructure: Read from cache; <openedx.core.djangoapps.content.block_structure.store.StubModel object at 0x7fc16df21d10>, size: 27906
Oct 15 00:37:40 vagrant [service_variant=lms][lms.djangoapps.grades.new.course_grade_factory][env:sandbox] INFO [vagrant  9658] [course_grade_factory.py:226] - Grades: Update, Course: course_key: course-v1:edX+DemoX+Demo_Course, version: 5bb02b9e636239465f78ab68, edited_on: 2018-09-30 01:49:18.055000+00:00, grading_policy: 2HDb6cWz6xgUQ8b9YhsgN5sukP0=, User: 4, Course Grade: percent: 0.0, letter_grade: None, passed: False, persisted: False
Oct 15 00:37:40 vagrant [service_variant=lms][openedx.core.djangoapps.content.block_structure.store][env:sandbox] INFO [vagrant  9658] [store.py:176] - BlockStructure: Read from cache; <openedx.core.djangoapps.content.block_structure.store.StubModel object at 0x7fc16e057090>, size: 27906
Oct 15 00:37:41 vagrant [service_variant=lms][lms.djangoapps.grades.new.course_grade_factory][env:sandbox] INFO [vagrant  9658] [course_grade_factory.py:226] - Grades: Update, Course: course_key: course-v1:edX+DemoX+Demo_Course, version: 5bb02b9e636239465f78ab68, edited_on: 2018-09-30 01:49:18.055000+00:00, grading_policy: 2HDb6cWz6xgUQ8b9YhsgN5sukP0=, User: 5, Course Grade: percent: 0.0, letter_grade: None, passed: False, persisted: False

==> /edx/var/log/nginx/access.log <==
- - 192.168.56.1 - - [15/Oct/2018:00:37:41 +0000]  "GET /figures/api/users/detail/?enrolled_in_course_id=course-v1:edX+DemoX+Demo_Course HTTP/1.1" 404 57 1.285 "http://192.168.56.10/figures/course/course-v1:edX+DemoX+Demo_Course" "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36" (edited)
jerrybox commented 5 years ago

Ginkgo Vagrant version

jerrybox commented 5 years ago

404 response of http://192.168.56.10/figures/api/users/detail/?enrolled_in_course_id=course-v1:edX+DemoX+Demo_Course
200 response of http://192.168.56.10/figures/api/learners/detail/?enrolled_in_course_id=course-v1:edX+DemoX+Demo_Course
Is it an error?

jerrybox commented 5 years ago
jerrybox commented 5 years ago
class LearnerDetailsViewSet(CommonAuthMixin, viewsets.ReadOnlyModelViewSet):

    queryset = get_user_model().objects.all()
    pagination_class = FiguresLimitOffsetPagination
    serializer_class = LearnerDetailsSerializer
    filter_backends = (DjangoFilterBackend, )
    filter_class = UserFilterSet

    def get_queryset(self):
        '''
        <QueryDict: {u'foo': [u'bar'], u'ids': [u'1,2,3']}>
        http://localhost:8000/figures/api/learners/detail/?ids=1,2,3&foo=bar&grue=11&grue=2&grue=3&zub=[5,10,20]
        self.request.query_params
        <QueryDict: {u'zub': [u'[5,10,20]'], u'grue': [u'11', u'2', u'3'],
        u'foo': [u'bar'], u'ids': [u'1,2,3']}>
        '''
        queryset = super(LearnerDetailsViewSet, self).get_queryset()
        return queryset
johnbaldwin commented 5 years ago

@jerrybox Thanks for submitting this bug!

In order to help understand this better, I have some questions:

A) Which are you running Ginkgo for your Vagrant environment? devstack or fullstack?

B) How are you installing Figures? using the production installation instructions or the devstack installation instructions?

C) As the edxapp user, when you type pip list | grep -i figures what do you see?

I've commented on what I think are the errors you are describing below to make sure I'm not missing something:

It seems you are reporting two errors and a documentation issue.

1) 404 on the /figures/api/users/ endpoint, but a 200 on /figures/api/learners/

The front end should be making calls to figures/api/users/ and shouldn't be making calls to /figures/api/learners/. These are the endpoints that the frontend goes to: https://github.com/appsembler/figures/blob/0.1.3/frontend/src/apiConfig.js

And these are the endpoints for the Figures Django reusable app: https://github.com/appsembler/figures/blob/0.1.3/figures/urls.py

2) InvalidKeyError

InvalidKeyError: <class 'opaque_keys.edx.locator.CourseLocator'>: detail/course-v1:edX+DemoX+Demo_Course

The error itself is showing detail/ as part of the course key string, which is clearly wrong, but I don't see where it traces back to a figures API call in the /edx/var/log/lms/edx.log fragment you pasted above. You say you are getting this when your browser is at the http://192.168.56.10/figures/course/course-v1:edX+DemoX+Demo_Course url?

3) Invalid url in Docstring

I've fixed (locally, still need to push to GH) the docstring in the LearnerDetailsViewSet.get_queryset method. Should be /figures/api/users/detail/?<query params>. But of course, that isn't causing the errors you are seeing.

jerrybox commented 5 years ago

Thanks very much.

Part One Answer

A)edx: fullstack with vagrant-images_ginkgo-fullstack-2017-08-14.box B)production installation instructions C)result of 'pip list | grep -i figures' as follow: Figures (0.1.3, /edx/app/edxapp/venvs/edxapp/src/figures)

Part Two Answer

  1. Yes, /figures/api/learners/ request is manual by me because of the docstring of the LarnerDetailsViewSet

  2. image

jerrybox commented 5 years ago

edxapp@vagrant:~/edx-platform$ git log -1 commit 37052afe316f14c61ab5c799434e4610b9d2d912 (HEAD -> nedbat/test/ginkgo.1.1, origin/open-release/ginkgo.master, origin/nedbat/test/ginkgo.1.1) Merge: 83ebc23198 ea5ac4988a Author: Ned Batchelder ned@nedbatchelder.com Date: Thu Aug 10 10:36:20 2017 -0400

Merge pull request #15781 from edx/nedbat/learner-2172-ginkgo

Host poisoning vulnerability fix
johnbaldwin commented 5 years ago

@jerrybox Thanks! The extra info helps me understand your environment better. I can't tell yet why you are getting a 404 on the <host>/figures/api/learners/detail/?enrolled_in_course_id=course-v1:edX+DemoX+Demo_Course

Some more questions to try to trace this down:

A) What do you get for results when you go to the <host>/figures/api/ path? This checks that you are getting the API root. B) What do you get for <host>/figures/api/users/detail/ (This checks that you can get the users detail endpoint and the issue would be with the query parameter) C) What do you see when you go to the <host>/courses/course-v1:edX+DemoX+Demo_Course URL? Do you see the course page?

D) Are you able to see the Figures UI page at <host>/figures/?

Thanks!

jerrybox commented 5 years ago

I am sorry for having kept you waiting for such a long time

A) log as follow:

image

B) log as follow:

image

C) I can see the course page.

D) I can see the figures homepage as follow:

image

johnbaldwin commented 5 years ago

@jerrybox

At this point, I'm just trying to narrow down what the issue could be by ruling out what the issue cannot be. What I'm thinking right now is one of two things:

A) Figures has a bug in unicode support for the users part of the API

B) There's some bad data the users API is trying to get causing the failure

I'm inclined to think it is "A" and that I need to add in unicode testing.

Just one thing that is interesting is that I should have put the paths in quotes instead of backticks because the call to "/figures/api/path/?" just drops to a catch all url. But that's ok, What I was checking was that the Figures app was found in lms/urls.py

Meanwhile, if you just want to test drive the UI with mock data, check out the "devsite-demo" branch: https://github.com/appsembler/figures/tree/devsite-demo

There is a (minimal) readme: https://github.com/appsembler/figures/blob/devsite-demo/devsite-demo-setup.txt

But it walks through the steps to setup, seed mock data and run the UI in a Figures standalone server. Right now this is JUST for exploring Figures, doing Figures development, etc not for production use

johnbaldwin commented 5 years ago

@jerrybox Are you still running into the same issues?

jerrybox commented 5 years ago

I am too busy to work it out.