Create hosting-service-account over web api

34 views
Skip to first unread message

testuser testuser

unread,
Nov 1, 2022, 4:47:40 PM11/1/22
to Review Board Development
Hi,

im trying to create a hosting-service-account over URI: /api/hosting-service-accounts/
in a python script. my code:

def create_account():
    data = {
        "service_id":"gitlab",
        "username":"username",
        "hosting_url":"https://gitlab..."
    }
    header =  {"Authorization": "token ..."}
    x = requests.post(url = url, data = data, headers = header)

and I always get the following error:
ERROR:root:Unexpected error when linking GitLab account for <WSGIRequest: POST '/api/hosting-service-accounts/'>: string indices must be integers

can somebody please help me to fix this issue.
Thank you! :)

Christian Hammond

unread,
Nov 1, 2022, 7:27:32 PM11/1/22
to reviewb...@googlegroups.com
Hi,

Can you check the Review Board server log and see if there’s a stack trace for this?

What version of Review Board is this using?

Christian


--

---
You received this message because you are subscribed to the Google Groups "Review Board Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to reviewboard-d...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/reviewboard-dev/5f5195c8-b713-42a8-a380-bab0768380fbn%40googlegroups.com.
--
--
Christian Hammond
President/CEO of Beanbag
Makers of Review Board

testuser testuser

unread,
Nov 3, 2022, 1:52:16 PM11/3/22
to Review Board Development
Hi, first of all, thank you for your help!
I use the docker-compose approach that I found on your reviewboard github repository
on localhost. Because of that i think it uses Reviewboard version 5.0
Strange thing is, that it works when the service_id is googlecode but with gitlab or github
it is not working.

The error I get is the following:


<!DOCTYPE html>

<html>
 <head>
  <title>500 - Internal Server Error | Review Board</title>
 </head>
 <body>
  <h1>Something broke! (Error 500)</h1>
  <p>
   It appears something broke when you tried to go to here. This is either
   a bug in Review Board or a server configuration error. Please report
   this to your administrator.
  </p>
 </body>
</title>


where can i find the reviewboard server logs?
I just found the docker logs
stack trace:

ERROR:root:Unexpected error when linking GitLab account for <WSGIRequest: POST '/api/hosting-service-accounts/'>: string indices must be integers
reviewboard_postgres-reviewboard-1  | Traceback (most recent call last):
reviewboard_postgres-reviewboard-1  |   File "/venv/lib/python3.8/site-packages/reviewboard/hostingsvcs/gitlab.py", line 342, in authorize
reviewboard_postgres-reviewboard-1  |     'PRIVATE-TOKEN': credentials['private_token'],
reviewboard_postgres-reviewboard-1  | TypeError: string indices must be integers
reviewboard_postgres-reviewboard-1  | ERROR:djblets.log.middleware:Exception thrown for user ******* at https://127.0.0.1/api/hosting-service-accounts/
reviewboard_postgres-reviewboard-1  |
reviewboard_postgres-reviewboard-1  | Unexpected error "string indices must be integers"
reviewboard_postgres-reviewboard-1  | Traceback (most recent call last):
reviewboard_postgres-reviewboard-1  |   File "/venv/lib/python3.8/site-packages/reviewboard/hostingsvcs/gitlab.py", line 342, in authorize
reviewboard_postgres-reviewboard-1  |     'PRIVATE-TOKEN': credentials['private_token'],
reviewboard_postgres-reviewboard-1  | TypeError: string indices must be integers
reviewboard_postgres-reviewboard-1  |
reviewboard_postgres-reviewboard-1  | During handling of the above exception, another exception occurred:
reviewboard_postgres-reviewboard-1  |
reviewboard_postgres-reviewboard-1  | Traceback (most recent call last):
reviewboard_postgres-reviewboard-1  |   File "/venv/lib/python3.8/site-packages/django/core/handlers/base.py", line 181, in _get_response
reviewboard_postgres-reviewboard-1  |     response = wrapped_callback(request, *callback_args, **callback_kwargs)
reviewboard_postgres-reviewboard-1  |   File "/venv/lib/python3.8/site-packages/django/views/decorators/cache.py", line 44, in _wrapped_view_func
reviewboard_postgres-reviewboard-1  |     response = view_func(request, *args, **kwargs)
reviewboard_postgres-reviewboard-1  |   File "/venv/lib/python3.8/site-packages/django/views/decorators/vary.py", line 20, in inner_func
reviewboard_postgres-reviewboard-1  |     response = func(*args, **kwargs)
reviewboard_postgres-reviewboard-1  |   File "/venv/lib/python3.8/site-packages/djblets/webapi/resources/base.py", line 228, in __call__
reviewboard_postgres-reviewboard-1  |     result = self.call_method_view(
reviewboard_postgres-reviewboard-1  |   File "/venv/lib/python3.8/site-packages/reviewboard/webapi/base.py", line 348, in call_method_view
reviewboard_postgres-reviewboard-1  |     return super(WebAPIResource, self).call_method_view(
reviewboard_postgres-reviewboard-1  |   File "/venv/lib/python3.8/site-packages/djblets/webapi/resources/mixins/api_tokens.py", line 62, in call_method_view
reviewboard_postgres-reviewboard-1  |     return super(ResourceAPITokenMixin, self).call_method_view(
reviewboard_postgres-reviewboard-1  |   File "/venv/lib/python3.8/site-packages/djblets/webapi/resources/mixins/oauth2_tokens.py", line 99, in call_method_view
reviewboard_postgres-reviewboard-1  |     return super(ResourceOAuth2TokenMixin, self).call_method_view(
reviewboard_postgres-reviewboard-1  |   File "/venv/lib/python3.8/site-packages/djblets/webapi/resources/base.py", line 375, in call_method_view
reviewboard_postgres-reviewboard-1  |     return view(request, *args, **kwargs)
reviewboard_postgres-reviewboard-1  |   File "/venv/lib/python3.8/site-packages/djblets/webapi/resources/base.py", line 476, in post
reviewboard_postgres-reviewboard-1  |     return self.create(*args, **kwargs)
reviewboard_postgres-reviewboard-1  |   File "/venv/lib/python3.8/site-packages/djblets/webapi/decorators.py", line 156, in _call
reviewboard_postgres-reviewboard-1  |     return view_func(*args, **kwargs)
reviewboard_postgres-reviewboard-1  |   File "/venv/lib/python3.8/site-packages/reviewboard/webapi/decorators.py", line 170, in _check
reviewboard_postgres-reviewboard-1  |     return view_func(*args, **kwargs)
reviewboard_postgres-reviewboard-1  |   File "/venv/lib/python3.8/site-packages/djblets/webapi/decorators.py", line 156, in _call
reviewboard_postgres-reviewboard-1  |     return view_func(*args, **kwargs)
reviewboard_postgres-reviewboard-1  |   File "/venv/lib/python3.8/site-packages/djblets/webapi/decorators.py", line 177, in _checklogin
reviewboard_postgres-reviewboard-1  |     return view_func(*args, **kwargs)
reviewboard_postgres-reviewboard-1  |   File "/venv/lib/python3.8/site-packages/djblets/webapi/decorators.py", line 156, in _call
reviewboard_postgres-reviewboard-1  |     return view_func(*args, **kwargs)
reviewboard_postgres-reviewboard-1  |   File "/venv/lib/python3.8/site-packages/djblets/webapi/decorators.py", line 156, in _call
reviewboard_postgres-reviewboard-1  |     return view_func(*args, **kwargs)
reviewboard_postgres-reviewboard-1  |   File "/venv/lib/python3.8/site-packages/djblets/webapi/decorators.py", line 322, in _validate
reviewboard_postgres-reviewboard-1  |     return view_func(*args, **new_kwargs)
reviewboard_postgres-reviewboard-1  |   File "/venv/lib/python3.8/site-packages/reviewboard/webapi/resources/hosting_service_account.py", line 202, in create
reviewboard_postgres-reviewboard-1  |     service.authorize(request, username, password, hosting_url,
reviewboard_postgres-reviewboard-1  |   File "/venv/lib/python3.8/site-packages/reviewboard/hostingsvcs/gitlab.py", line 362, in authorize
reviewboard_postgres-reviewboard-1  |     raise HostingServiceError(
reviewboard_postgres-reviewboard-1  | reviewboard.hostingsvcs.errors.HostingServiceError: Unexpected error "string indices must be integers"
reviewboard_postgres-reviewboard-1  | ERROR:django.request:Internal Server Error: /api/hosting-service-accounts/
reviewboard_postgres-reviewboard-1  | Traceback (most recent call last):
reviewboard_postgres-reviewboard-1  |   File "/venv/lib/python3.8/site-packages/reviewboard/hostingsvcs/gitlab.py", line 342, in authorize
reviewboard_postgres-reviewboard-1  |     'PRIVATE-TOKEN': credentials['private_token'],
reviewboard_postgres-reviewboard-1  | TypeError: string indices must be integers

Christian Hammond

unread,
Nov 4, 2022, 3:06:06 AM11/4/22
to reviewb...@googlegroups.com
Looks like there's a bug in the API. It's passing an incorrect parameter to the hosting service authorization code. We'll have to fix this for 5.0.2, I'm afraid (we can send backports/patches under support contracts, but otherwise it'll have to wait until the next release).

If all instances are going to use the same database, you may be better off not scripting this, but instead creating the accounts manually. An account can be shared across any number of repositories, and isn't needed per-logged-in user. Most installs use only one per hosting service.

Christian


--
Christian Hammond
President/CEO of Beanbag
Makers of Review Board

Reply all
Reply to author
Forward
0 new messages