Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

groups with no members or sponsors causes 500 #444

Closed
nirik opened this issue Feb 20, 2023 · 2 comments · Fixed by #555
Closed

groups with no members or sponsors causes 500 #444

nirik opened this issue Feb 20, 2023 · 2 comments · Fixed by #555
Assignees
Labels
bug Something isn't working deployed:prod This has been deployed to production deployed:staging This has been deployed to staging EasyFix Good for newcomers

Comments

@nirik
Copy link
Member

nirik commented Feb 20, 2023

Similar to #399 if there is a group with no members/sponsors, fasjson returns a 500:

[Mon Feb 20 19:04:11.774116 2023] [wsgi:error] [pid 5882:tid 5885] [remote 10.131.0.1:44354] [2023-02-20 19:04:11,772] ERROR in app: Exception on /v1/groups/gitlab-centos-sig-altimages/sponsors/ [GET]
[Mon Feb 20 19:04:11.774150 2023] [wsgi:error] [pid 5882:tid 5885] [remote 10.131.0.1:44354] Traceback  (most recent call last):
[Mon Feb 20 19:04:11.774153 2023] [wsgi:error] [pid 5882:tid 5885] [remote 10.131.0.1:44354]   File "/opt/venv/lib64/python3.10/site-packages/flask/app.py", line 1517, in full_dispatch_request
[Mon Feb 20 19:04:11.774156 2023] [wsgi:error] [pid 5882:tid 5885] [remote 10.131.0.1:44354]     rv = self.dispatch_request()
[Mon Feb 20 19:04:11.774158 2023] [wsgi:error] [pid 5882:tid 5885] [remote 10.131.0.1:44354]   File "/opt/venv/lib64/python3.10/site-packages/flask/app.py", line 1503, in dispatch_request
[Mon Feb 20 19:04:11.774161 2023] [wsgi:error] [pid 5882:tid 5885] [remote 10.131.0.1:44354]     return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
[Mon Feb 20 19:04:11.774164 2023] [wsgi:error] [pid 5882:tid 5885] [remote 10.131.0.1:44354]   File "/opt/venv/lib64/python3.10/site-packages/flask_restx/api.py", line 403, in wrapper
[Mon Feb 20 19:04:11.774167 2023] [wsgi:error] [pid 5882:tid 5885] [remote 10.131.0.1:44354]     resp = resource(*args, **kwargs)
[Mon Feb 20 19:04:11.774170 2023] [wsgi:error] [pid 5882:tid 5885] [remote 10.131.0.1:44354]   File "/opt/venv/lib64/python3.10/site-packages/flask/views.py", line 84, in view
[Mon Feb 20 19:04:11.774179 2023] [wsgi:error] [pid 5882:tid 5885] [remote 10.131.0.1:44354]     return current_app.ensure_sync(self.dispatch_request)(*args, **kwargs)
[Mon Feb 20 19:04:11.774187 2023] [wsgi:error] [pid 5882:tid 5885] [remote 10.131.0.1:44354]   File "/opt/venv/lib64/python3.10/site-packages/flask_restx/resource.py", line 49, in dispatch_request
[Mon Feb 20 19:04:11.774194 2023] [wsgi:error] [pid 5882:tid 5885] [remote 10.131.0.1:44354]     resp = meth(*args, **kwargs)
[Mon Feb 20 19:04:11.774201 2023] [wsgi:error] [pid 5882:tid 5885] [remote 10.131.0.1:44354]   File "/opt/venv/lib64/python3.10/site-packages/flask_restx/marshalling.py", line 248, in wrapper
[Mon Feb 20 19:04:11.774208 2023] [wsgi:error] [pid 5882:tid 5885] [remote 10.131.0.1:44354]     resp = f(*args, **kwargs)
[Mon Feb 20 19:04:11.774214 2023] [wsgi:error] [pid 5882:tid 5885] [remote 10.131.0.1:44354]   File "/fasjson/fasjson/web/resources/groups.py", line 107, in get
[Mon Feb 20 19:04:11.774220 2023] [wsgi:error] [pid 5882:tid 5885] [remote 10.131.0.1:44354]     return client.get_group_sponsors(
[Mon Feb 20 19:04:11.774228 2023] [wsgi:error] [pid 5882:tid 5885] [remote 10.131.0.1:44354]   File "/fasjson/fasjson/lib/ldap/client.py", line 110, in get_group_sponsors
[Mon Feb 20 19:04:11.774234 2023] [wsgi:error] [pid 5882:tid 5885] [remote 10.131.0.1:44354]     return self._sponsors_to_users(sponsors_result, attrs)
[Mon Feb 20 19:04:11.774239 2023] [wsgi:error] [pid 5882:tid 5885] [remote 10.131.0.1:44354]   File "/fasjson/fasjson/lib/ldap/client.py", line 116, in _sponsors_to_users
[Mon Feb 20 19:04:11.774246 2023] [wsgi:error] [pid 5882:tid 5885] [remote 10.131.0.1:44354]     username = re.findall("(?<=uid=)([^,]+)", sponsor)[0]
[Mon Feb 20 19:04:11.774251 2023] [wsgi:error] [pid 5882:tid 5885] [remote 10.131.0.1:44354] IndexError: list index out of range

I would think it should return 0 or [] or something. ;)

@nirik
Copy link
Member Author

nirik commented Feb 20, 2023

It turns out the group did have managers... but it was... another group and fasjson doesn't know what to do with that.

So, it should likely look and if there's groups that are managers, query for their members and return all of them?

Or just return the group(s) with some indication it's a group and not a user?

@abompard abompard added the bug Something isn't working label Apr 25, 2023
@abompard abompard added the EasyFix Good for newcomers label Jul 6, 2023
@LenkaSeg LenkaSeg self-assigned this Jul 24, 2023
@LenkaSeg
Copy link
Contributor

LenkaSeg commented Jul 27, 2023

Steps to reproduce:

Start tiny-stage:
vagrant up

Go to https://ipa.tinystage.test/ipa
Log in as admin, password: password

Add group in the UI

Set up the authentication as described in tiny-stage readme:
echo password | KRB5_CONFIG=krb5.conf kinit admin

curl to fasjson tiny-stage:
KRB5_CONFIG=krb5.conf curl --cacert ./synced_folders/ipa/ca.crt -u : --negotiate https://fasjson.tinystage.test/fasjson/v1/me/

Add group member managers => User Groups => add a group

Query fasjson:
KRB5_CONFIG=krb5.conf curl --cacert ./synced_folders/ipa/ca.crt -u : --negotiate https://fasjson.tinystage.test/fasjson/v1/me/`

Query group:
KRB5_CONFIG=krb5.conf curl --cacert ./synced_folders/ipa/ca.crt -u : --negotiate https://fasjson.tinystage.test/fasjson/v1/groups/test-group/sponsors/

Result:
{"message": "Internal Server Error"}

Working on a fix :)

LenkaSeg added a commit to LenkaSeg/fasjson that referenced this issue Aug 28, 2023
Fixes: fedora-infra#444
Signed-off-by: Aurelien Bompard <abompard@redhat.com>
Signed-off-by: Lenka Segura <lsegura@redhat.com>
@mergify mergify bot closed this as completed in #555 Aug 31, 2023
mergify bot pushed a commit that referenced this issue Aug 31, 2023
Fixes: #444
Signed-off-by: Aurelien Bompard <abompard@redhat.com>
Signed-off-by: Lenka Segura <lsegura@redhat.com>
@github-actions github-actions bot added the deployed:staging This has been deployed to staging label Sep 1, 2023
@abompard abompard removed the deployed:staging This has been deployed to staging label Sep 1, 2023
@github-actions github-actions bot added deployed:staging This has been deployed to staging deployed:prod This has been deployed to production labels Sep 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working deployed:prod This has been deployed to production deployed:staging This has been deployed to staging EasyFix Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants