[image: Screenshot 2024-08-14 115239.png] Looks like we are using the latest version. On Wednesday 14 August 2024 at 11:40:19 UTC-4 David Trowbridge wrote:
> Hi, > > Looks like we've got a bug in the hosting service account resource. > > What version of Review Board are you using? > > David > > On Wed, Aug 14, 2024 at 9:35 AM FeedJ <ejfat...@gmail.com> wrote: > >> Hi, I am currently trying to write python automation scripts to try and >> automatically add hosting services account without needing to manually have >> an admin add them in the admin panel. Whenever I execute my script, I get >> an http 500 error thrown at me. Oddly enough this only happens when trying >> to add a hosting account. When I try to add a repository using the Python >> API, it works well with no issue. >> >> This script is running with the superadmin user logged in so I doubt it >> would be an access rights issue. Any idea on what could be done to fix this? >> >> This is what my script looks like: >> >> from rbtools.api.client import RBClient >> >> # Replace these with your Review Board server details >> server_url = 'http://rbserver.review >> rb_username = 'admin' >> rb_password = 'admin' >> >> # Authenticate with the Review Board server >> client = RBClient(server_url, username=rb_username, password=rb_password) >> >> # Grab the root API >> root = client.get_root() >> print(f"Connection to ReviewBoard server '{server_url}' succesful.") >> >> hosting_accounts = root.get_hosting_service_accounts() >> >> hosting_accounts.create( >> username=username, >> hosting_url=gitlab_server_url, >> password=gitlab_acc_token, >> service_id='gitlab' >> ) >> >> >> This is what the python console prints out: >> >> Connection to ReviewBoard server 'http://rbserver.review' succesful. >> Traceback (most recent call last): >> File >> "/home/fattouchJ/.local/lib/python3.9/site-packages/rbtools/api/request.py", >> line 1278, in process_error >> rsp = json_loads(data_str) >> File "/usr/lib64/python3.9/json/__init__.py", line 346, in loads >> return _default_decoder.decode(s) >> File "/usr/lib64/python3.9/json/decoder.py", line 337, in decode >> obj, end = self.raw_decode(s, idx=_w(s, 0).end()) >> File "/usr/lib64/python3.9/json/decoder.py", line 355, in raw_decode >> raise JSONDecodeError("Expecting value", s, err.value) from None >> json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0) >> >> During handling of the above exception, another exception occurred: >> >> Traceback (most recent call last): >> File "/home/fattouchJ/rb_setup/add_hosting_acc.py", line 19, in <module> >> hosting_accounts.create( >> File >> "/home/fattouchJ/.local/lib/python3.9/site-packages/rbtools/api/resource.py", >> >> line 325, in <lambda> >> meth(resource, **kwargs))) >> File >> "/home/fattouchJ/.local/lib/python3.9/site-packages/rbtools/api/decorators.py", >> >> line 23, in request_method >> return self._transport.execute_request_method(method_wrapper, >> File >> "/home/fattouchJ/.local/lib/python3.9/site-packages/rbtools/api/transport/sync.py", >> >> line 314, in execute_request_method >> return self._execute_request(request) >> File >> "/home/fattouchJ/.local/lib/python3.9/site-packages/rbtools/api/transport/sync.py", >> >> line 335, in _execute_request >> rsp = self.server.make_request(request) >> File >> "/home/fattouchJ/.local/lib/python3.9/site-packages/rbtools/api/request.py", >> line 1323, in make_request >> self.process_error(e.code, e.read()) >> File >> "/home/fattouchJ/.local/lib/python3.9/site-packages/rbtools/api/request.py", >> line 1290, in process_error >> raise APIError(http_status, None, None, data_str) >> rbtools.api.errors.APIError: <!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> >> (HTTP 500: Internal Server Error) >> >> And finally this is the content of the log file: >> >> 2024-08-14 15:00:19,262 - DEBUG - None - AnonymousUser - /api/ - >> djblets.webapi.auth.backends.base - Attempting authentication on API: >> username=admin, password=************ >> 2024-08-14 15:00:19,965 - ERROR - - reviewboard.hostingsvcs.gitlab - >> Unexpected error when linking GitLab account for <WSGIRequest: POST >> '/api/hosting-service-accounts/'>: string indices must be integers, not >> 'str' >> Traceback (most recent call last): >> File >> "/venv/lib/python3.11/site-packages/reviewboard/hostingsvcs/gitlab.py", >> line 345, in authorize >> 'PRIVATE-TOKEN': credentials['private_token'], >> ~~~~~~~~~~~^^^^^^^^^^^^^^^^^ >> TypeError: string indices must be integers, not 'str' >> 2024-08-14 15:00:19,966 - ERROR - None - admin - >> /api/hosting-service-accounts/ - djblets.log.middleware - Exception thrown >> for user admin at http://rbserver.review/api/hosting-service-accounts/ >> >> Unexpected error "string indices must be integers, not 'str'" >> Traceback (most recent call last): >> File >> "/venv/lib/python3.11/site-packages/reviewboard/hostingsvcs/gitlab.py", >> line 345, in authorize >> 'PRIVATE-TOKEN': credentials['private_token'], >> ~~~~~~~~~~~^^^^^^^^^^^^^^^^^ >> TypeError: string indices must be integers, not 'str' >> >> During handling of the above exception, another exception occurred: >> >> Traceback (most recent call last): >> File "/venv/lib/python3.11/site-packages/django/core/handlers/base.py", >> line 197, in _get_response >> response = wrapped_callback(request, *callback_args, >> **callback_kwargs) >> >> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >> File >> "/venv/lib/python3.11/site-packages/django/views/decorators/vary.py", line >> 21, in inner_func >> response = func(*args, **kwargs) >> ^^^^^^^^^^^^^^^^^^^^^ >> File >> "/venv/lib/python3.11/site-packages/djblets/webapi/resources/base.py", line >> 650, in __call__ >> result = self.call_method_view( >> ^^^^^^^^^^^^^^^^^^^^^^ >> File "/venv/lib/python3.11/site-packages/reviewboard/webapi/base.py", >> line 360, in call_method_view >> return super(WebAPIResource, self).call_method_view( >> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >> File >> "/venv/lib/python3.11/site-packages/djblets/webapi/resources/mixins/api_tokens.py", >> >> line 62, in call_method_view >> return super(ResourceAPITokenMixin, self).call_method_view( >> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >> File >> "/venv/lib/python3.11/site-packages/djblets/webapi/resources/mixins/oauth2_tokens.py", >> >> line 99, in call_method_view >> return super(ResourceOAuth2TokenMixin, self).call_method_view( >> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >> File >> "/venv/lib/python3.11/site-packages/djblets/webapi/resources/base.py", line >> 941, in call_method_view >> return view(request, *args, **kwargs) >> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >> File >> "/venv/lib/python3.11/site-packages/djblets/webapi/resources/base.py", line >> 1123, in post >> return self.create(request, >> ^^^^^^^^^^^^^^^^^^^^ >> File "/venv/lib/python3.11/site-packages/djblets/webapi/decorators.py", >> line 175, in _call >> return view_func(*args, **kwargs) >> ^^^^^^^^^^^^^^^^^^^^^^^^^^ >> File >> "/venv/lib/python3.11/site-packages/reviewboard/webapi/decorators.py", line >> 176, in _check >> return view_func(*args, **kwargs) >> ^^^^^^^^^^^^^^^^^^^^^^^^^^ >> File "/venv/lib/python3.11/site-packages/djblets/webapi/decorators.py", >> line 175, in _call >> return view_func(*args, **kwargs) >> ^^^^^^^^^^^^^^^^^^^^^^^^^^ >> File "/venv/lib/python3.11/site-packages/djblets/webapi/decorators.py", >> line 196, in _checklogin >> return view_func(*args, **kwargs) >> ^^^^^^^^^^^^^^^^^^^^^^^^^^ >> File "/venv/lib/python3.11/site-packages/djblets/webapi/decorators.py", >> line 175, in _call >> return view_func(*args, **kwargs) >> ^^^^^^^^^^^^^^^^^^^^^^^^^^ >> File "/venv/lib/python3.11/site-packages/djblets/webapi/decorators.py", >> line 175, in _call >> return view_func(*args, **kwargs) >> ^^^^^^^^^^^^^^^^^^^^^^^^^^ >> File "/venv/lib/python3.11/site-packages/djblets/webapi/decorators.py", >> line 342, in _validate >> return view_func(*args, **new_kwargs) >> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >> File >> "/venv/lib/python3.11/site-packages/reviewboard/webapi/resources/hosting_service_account.py", >> >> line 200, in create >> service.authorize(request, username, password, hosting_url, >> File >> "/venv/lib/python3.11/site-packages/reviewboard/hostingsvcs/gitlab.py", >> line 365, in authorize >> raise HostingServiceError( >> reviewboard.hostingsvcs.errors.HostingServiceError: Unexpected error >> "string indices must be integers, not 'str'" >> 2024-08-14 15:00:19,969 - ERROR - None - admin - >> /api/hosting-service-accounts/ - django.request - Internal Server Error: >> /api/hosting-service-accounts/ >> Traceback (most recent call last): >> File >> "/venv/lib/python3.11/site-packages/reviewboard/hostingsvcs/gitlab.py", >> line 345, in authorize >> 'PRIVATE-TOKEN': credentials['private_token'], >> ~~~~~~~~~~~^^^^^^^^^^^^^^^^^ >> TypeError: string indices must be integers, not 'str' >> >> During handling of the above exception, another exception occurred: >> >> Traceback (most recent call last): >> File >> "/venv/lib/python3.11/site-packages/django/core/handlers/exception.py", >> line 55, in inner >> response = get_response(request) >> ^^^^^^^^^^^^^^^^^^^^^ >> File "/venv/lib/python3.11/site-packages/django/core/handlers/base.py", >> line 197, in _get_response >> response = wrapped_callback(request, *callback_args, >> **callback_kwargs) >> >> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >> File >> "/venv/lib/python3.11/site-packages/django/views/decorators/vary.py", line >> 21, in inner_func >> response = func(*args, **kwargs) >> ^^^^^^^^^^^^^^^^^^^^^ >> File >> "/venv/lib/python3.11/site-packages/djblets/webapi/resources/base.py", line >> 650, in __call__ >> result = self.call_method_view( >> ^^^^^^^^^^^^^^^^^^^^^^ >> File "/venv/lib/python3.11/site-packages/reviewboard/webapi/base.py", >> line 360, in call_method_view >> return super(WebAPIResource, self).call_method_view( >> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >> File >> "/venv/lib/python3.11/site-packages/djblets/webapi/resources/mixins/api_tokens.py", >> >> line 62, in call_method_view >> return super(ResourceAPITokenMixin, self).call_method_view( >> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >> File >> "/venv/lib/python3.11/site-packages/djblets/webapi/resources/mixins/oauth2_tokens.py", >> >> line 99, in call_method_view >> return super(ResourceOAuth2TokenMixin, self).call_method_view( >> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >> File >> "/venv/lib/python3.11/site-packages/djblets/webapi/resources/base.py", line >> 941, in call_method_view >> return view(request, *args, **kwargs) >> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >> File >> "/venv/lib/python3.11/site-packages/djblets/webapi/resources/base.py", line >> 1123, in post >> return self.create(request, >> ^^^^^^^^^^^^^^^^^^^^ >> File "/venv/lib/python3.11/site-packages/djblets/webapi/decorators.py", >> line 175, in _call >> return view_func(*args, **kwargs) >> ^^^^^^^^^^^^^^^^^^^^^^^^^^ >> File >> "/venv/lib/python3.11/site-packages/reviewboard/webapi/decorators.py", line >> 176, in _check >> return view_func(*args, **kwargs) >> ^^^^^^^^^^^^^^^^^^^^^^^^^^ >> File "/venv/lib/python3.11/site-packages/djblets/webapi/decorators.py", >> line 175, in _call >> return view_func(*args, **kwargs) >> ^^^^^^^^^^^^^^^^^^^^^^^^^^ >> File "/venv/lib/python3.11/site-packages/djblets/webapi/decorators.py", >> line 196, in _checklogin >> return view_func(*args, **kwargs) >> ^^^^^^^^^^^^^^^^^^^^^^^^^^ >> File "/venv/lib/python3.11/site-packages/djblets/webapi/decorators.py", >> line 175, in _call >> return view_func(*args, **kwargs) >> ^^^^^^^^^^^^^^^^^^^^^^^^^^ >> File "/venv/lib/python3.11/site-packages/djblets/webapi/decorators.py", >> line 175, in _call >> return view_func(*args, **kwargs) >> ^^^^^^^^^^^^^^^^^^^^^^^^^^ >> File "/venv/lib/python3.11/site-packages/djblets/webapi/decorators.py", >> line 342, in _validate >> return view_func(*args, **new_kwargs) >> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >> File >> "/venv/lib/python3.11/site-packages/reviewboard/webapi/resources/hosting_service_account.py", >> >> line 200, in create >> service.authorize(request, username, password, hosting_url, >> File >> "/venv/lib/python3.11/site-packages/reviewboard/hostingsvcs/gitlab.py", >> line 365, in authorize >> raise HostingServiceError( >> reviewboard.hostingsvcs.errors.HostingServiceError: Unexpected error >> "string indices must be integers, not 'str'" >> 2024-08-14 15:00:24,341 - DEBUG - - root - Reloading logging settings >> 2024-08-14 15:00:24,345 - DEBUG - - root - Logging to >> /site/logs/reviewboard.log with a minimum level of DEBUG >> >> -- >> Supercharge your Review Board with Power Pack: >> https://www.reviewboard.org/powerpack/ >> Want us to host Review Board for you? Check out RBCommons: >> https://rbcommons.com/ >> Happy user? Let us know! https://www.reviewboard.org/users/ >> --- >> You received this message because you are subscribed to the Google Groups >> "Review Board Community" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to reviewboard...@googlegroups.com. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/reviewboard/a43928a7-e89b-4f53-9062-15c3ec781b8bn%40googlegroups.com >> >> <https://groups.google.com/d/msgid/reviewboard/a43928a7-e89b-4f53-9062-15c3ec781b8bn%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > -- Supercharge your Review Board with Power Pack: https://www.reviewboard.org/powerpack/ Want us to host Review Board for you? Check out RBCommons: https://rbcommons.com/ Happy user? Let us know! https://www.reviewboard.org/users/ --- You received this message because you are subscribed to the Google Groups "Review Board Community" group. To unsubscribe from this group and stop receiving emails from it, send an email to reviewboard+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/reviewboard/f43b546b-3fab-49e4-ac6c-335adb117048n%40googlegroups.com.