Repository navigation
OAuth Server Error 500 #45
Copy link
Copy link
Open
Description
Hi there !
I've managed to set it up following the Deploying on WMF Toolforge, but locally.
Now, at the stage I'm creating the User, after creating the OAuth keys and passing them to the secret.py, when I try to login for the first time (before creating the staff user within the shell) I get the following error (with DEBUG = True):
Django Version: | 2.1.15
-- | --
TypeError
Direct assignment to the forward side of a many-to-many set is prohibited. Use groups.set() instead.
/var/www/venv/lib/python3.6/site-packages/django/db/models/fields/related_descriptors.py in __set__, line 537
/var/www/venv/bin/python
3.6.9
['/var/www/src', '/usr/lib/python36.zip', '/usr/lib/python3.6', '/usr/lib/python3.6/lib-dynload', '/var/www/venv/lib/python3.6/site-packages']
Sat, 16 Apr 2022 02:23:54 +0000
Here is the Traceback:
Django Version: 2.1.15
Python Version: 3.6.9
Installed Applications:
('django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'social_django',
'django_filters',
'rest_framework',
'store',
'revert',
'tagging',
'django_extensions')
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'social_django.middleware.SocialAuthExceptionMiddleware']
Traceback:
File "/var/www/venv/lib/python3.6/site-packages/django/core/handlers/exception.py" in inner
34. response = get_response(request)
File "/var/www/venv/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
126. response = self.process_exception_by_middleware(e, request)
File "/var/www/venv/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
124. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/var/www/venv/lib/python3.6/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
44. response = view_func(request, *args, **kwargs)
File "/var/www/venv/lib/python3.6/site-packages/django/views/decorators/csrf.py" in wrapped_view
54. return view_func(*args, **kwargs)
File "/var/www/venv/lib/python3.6/site-packages/social_django/utils.py" in wrapper
46. return func(request, backend, *args, **kwargs)
File "/var/www/venv/lib/python3.6/site-packages/social_django/views.py" in complete
33. *args, **kwargs)
File "/var/www/venv/lib/python3.6/site-packages/social_core/actions.py" in do_complete
45. user = backend.complete(user=user, *args, **kwargs)
File "/var/www/venv/lib/python3.6/site-packages/social_core/backends/base.py" in complete
40. return self.auth_complete(*args, **kwargs)
File "/var/www/venv/lib/python3.6/site-packages/social_core/utils.py" in wrapper
247. return func(*args, **kwargs)
File "/var/www/venv/lib/python3.6/site-packages/social_core/backends/oauth.py" in auth_complete
181. return self.do_auth(access_token, *args, **kwargs)
File "/var/www/venv/lib/python3.6/site-packages/social_core/utils.py" in wrapper
247. return func(*args, **kwargs)
File "/var/www/venv/lib/python3.6/site-packages/social_core/backends/oauth.py" in do_auth
192. return self.strategy.authenticate(*args, **kwargs)
File "/var/www/venv/lib/python3.6/site-packages/social_django/strategy.py" in authenticate
105. return authenticate(*args, **kwargs)
File "/var/www/venv/lib/python3.6/site-packages/django/contrib/auth/__init__.py" in authenticate
73. user = backend.authenticate(request, **credentials)
File "/var/www/venv/lib/python3.6/site-packages/social_core/backends/base.py" in authenticate
80. return self.pipeline(pipeline, *args, **kwargs)
File "/var/www/venv/lib/python3.6/site-packages/social_core/backends/base.py" in pipeline
83. out = self.run_pipeline(pipeline, pipeline_index, *args, **kwargs)
File "/var/www/venv/lib/python3.6/site-packages/social_core/backends/base.py" in run_pipeline
113. result = func(*args, **out) or {}
File "/var/www/venv/lib/python3.6/site-packages/social_core/pipeline/user.py" in user_details
119. setattr(user, name, value)
File "/var/www/venv/lib/python3.6/site-packages/django/db/models/fields/related_descriptors.py" in __set__
537. % self._get_set_deprecation_msg_params(),
Exception Type: TypeError at /oauth/complete/mediawiki/
Exception Value: Direct assignment to the forward side of a many-to-many set is prohibited. Use groups.set() instead.
Do you guys have any idea how to fix it?
Thanks in advance
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
[-]settings.DATABASES is improperly configured. Please supply the ENGINE value[/-][+]OAuth Server Error 500[/+]edpomacedo commentedon Apr 16, 2022
Fixed !
Add the following to the
secret.py, as stated at social-app-django:And under
try:at__init__.py, add the following:wetneb commentedon Apr 16, 2022
Thanks a lot! Perhaps that is worth adding to the documentation?
Also, I am curious if you are deploying this for a non-WMF wiki, if you are deploying it outside of the toolforge?
edpomacedo commentedon Apr 16, 2022
You're welcome!
I'm working on a Wikibase to store Brazilian legal data. I had to set up my own in order to have strings and multilingual texts with more than 250 characters, so the content makes sense (i.e. case abstract).
After setting up the QuickStatements on the server and perform a few tests, I was able to import some batches to the Wikibase, but they were not recorded within QuickStatements. Also, I had to keep clicking the "Execute"/"Stop" button until the last item of the batch.
I saw that it has connections to the EditGroups tool, so I'm trying to deploy it too and see if things works out.
Right now I'm facing nginx/permissions problems regarding the
/admin/store/tool. As soon as I succeed, I'll paste the gist here and you see if it fits within the documentation. This is the Traceback:Any tips or guidance will be very much appreciated!
wetneb commentedon Apr 16, 2022
If it is just the admin interface that you fail to reach, then the user you are connected with probably does not have admin/superuser rights (you could try setting both).
Otherwise if it is for the entire app, then it could be that you have not set up your ALLOWED_HOSTS properly (in your Django settings).
But I should warn you that this tool relies on the WMF Event Stream to stay in sync with the Wikibase instance and I am not aware of any Wikibase instance that also deployed something similar - I suspect it is quite some effort to replicate Wikimedia's infrastructure.
wetneb commentedon Apr 16, 2022
(See python-social-auth/social-app-django#5)
edpomacedo commentedon Apr 17, 2022
Thank you for the heads up!
You are right. I'm afraid it will not be possible to make it work. Even with the ./listener.sh and the ./celery.sh running, I did not see any changes publicly.
Regarding the permission, I have access to the admin panel, but unable to edit or view anything there.
I would love to try an alternative. Btw, I asked for membership at toolforge.
Do you think the gist is still necessary? I've installed virtualenv, redis and some other dependencies to resume the requirements.txt that were returning errors. If you think so, I'll leave it here.
wetneb commentedon Apr 17, 2022
Ok! Well I do not think it would be that hard to add support for ingesting changes by polling the recent changes feed. But I just have not done it because I have no need for it myself. But if you are motivated I am keen to help you!
Initially there should not be much to see as the database is empty, but normally you should be able to create a new tool.
Which gist?
edpomacedo commentedon Apr 17, 2022
Awesome! Here it is: EditGroups. Something is off because of my tweaks. I'm considering to restore the VM and start again.
When I'm logged in, I try to go to /admin/store/tool/, it returns
403 Forbidden. I've tried to./manage.py createsuperuserand pass my username, it says "is already taken". So I'm wondering: what if I create the superuser before I log in via OAuth for the first time? Maybe something related to my nginx .conf? I can't really tell.The gist I'm referring to is the one that records my steps to reproduce the application, more or less like this:
edpomacedo commentedon Apr 17, 2022
Turning on
DEBUGmode and logged out, it looks like it's something regarding redis:Traceback:
When I'm logged in, the error related to the
/admin/store/tool/is the same reproduced above. And the admin panel returns the following:wetneb commentedon Apr 17, 2022
So, if you log in via OAuth, that will create a user account that will be different than any previously created account.
Now that you are in this situation, there are two solutions:
./manage.py createsuperuseror
./manage.py shelland input the following lines:This will make all existing users in EditGroups admins and superuser (obviously you only want to do that if no non-admin users have logged in via OAuth so far, you can check which users exist before executing the second line with
User.objects.all()).edpomacedo commentedon Apr 17, 2022
Good news! With the
rootuser created through step 1, I was able to navigate through the panel and even saw the tool creation form. Thats's great! But it looks like "pure html", nothing like the django admin panel.Then, for step 2, i got the following error:
Nonetheless, checking the
admin/auth/user/with the root user, I can see that my MediaWiki/OAuth user has Staff statustrue:Sadly, the
admin/store/tool/for the root user returnsServer Error (500). But when I point toadmin/store/tool/add/, I can see the form described at Configuring the supported tools.Should I start all over from scratch? Because with my MediaWiki user, I still have no "permission to view or edit anything".
wetneb commentedon Apr 17, 2022
Sorry, it was
is_staff, notis_admin. I am not sure about your 500 error, it is probably something we can debug if you setDEBUG = Truein your Django settings.edpomacedo commentedon Apr 17, 2022
NICE! Now my MediaWiki user has full access to the admin panel!
Now, browsing to the
/admin/store/tool/withDEBUGon, here's the error:Traceback:
I see it is making the request through
http:instead ofhttps:. Is that related?wetneb commentedon Apr 17, 2022
hmm that is curious, I am not sure where to go from there. Perhaps we should upgrade to a newer version of Django and other libraries.
edpomacedo commentedon Apr 17, 2022
I'm ready to do so. For the
requirements.txt, I had to declarecelery==5.*. Also, to themysqlclient==2.0.3, I had to installlibmysqlclient-dev,build-essentialandpython3-devin order to migrate without any errors.Do you have any suggestions on which libraries to use?
wetneb commentedon Apr 19, 2022
I would just try to upgrade them one by one to higher versions and fix any incompatibilities that I encounter on the way. Hopefully the CI can be of some help for this.
edpomacedo commentedon Apr 19, 2022
Ok! I will try again next weekend. Hopefully it works out.
I saw that you think it's possible to make it work with EventLogging... I read some of the documentation, and I learned that there is a backend to it too. Once I install both, the EditGroups will ingest the batches? Does it require further coding?
wetneb commentedon Apr 19, 2022
If you install EventLogging then it should be reasonably straightforward to adapt EditGroups to connect to the underlying cluster.
It will make it possible to undo any batch run after you start running the listener.
To enable reversion of batches you have already done, there could be multiple options: