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

User not found while syncing users with django #709

Open
filippomc opened this issue Sep 14, 2023 · 0 comments
Open

User not found while syncing users with django #709

filippomc opened this issue Sep 14, 2023 · 0 comments

Comments

@filippomc
Copy link
Collaborator

filippomc commented Sep 14, 2023

cloudharness_django/services/events.py in event_handler at line 36

KeycloakAuthenticationError: 401: b'{"error":"HTTP 401 Unauthorized"}'
  File "cloudharness/auth/keycloak.py", line 42, in wrapper
    return func(self, *args, **kwargs)
  File "cloudharness/auth/keycloak.py", line 440, in get_user
    user = admin_client.get_user(user_id)
  File "keycloak/keycloak_admin.py", line 727, in get_user
    return raise_error_from_response(data_raw, KeycloakGetError)
  File "keycloak/exceptions.py", line 192, in raise_error_from_response
    raise error(
KeycloakGetError: 404: b'{"error":"User not found"}'
  File "cloudharness/auth/keycloak.py", line 440, in get_user
    user = admin_client.get_user(user_id)
  File "keycloak/keycloak_admin.py", line 727, in get_user
    return raise_error_from_response(data_raw, KeycloakGetError)
  File "keycloak/exceptions.py", line 192, in raise_error_from_response
    raise error(
UserNotFound: 7a305088-b8fa-4285-afec-af9d6dc2ef13
  File "cloudharness/events/client.py", line 252, in _consume_task
    handler(event_client=self, app=app, message=message.value)
  File "cloudharness_django/services/events.py", line 50, in event_handler
    raise e
  File "cloudharness_django/services/events.py", line 36, in event_handler
    kc_user = auth_client.get_user(resource_path[1])
  File "cloudharness/auth/keycloak.py", line 45, in wrapper
    return func(self, *args, **kwargs)
  File "cloudharness/auth/keycloak.py", line 442, in get_user
    raise UserNotFound(user_id)

This is happening after a user is just create as can be seen from the event:

<cloudharness.events.client.EventClient object at 0x7f8e19f813a0> {'resource-type': 'USER', 'operation-type': 'CREATE', 'resource-path': 'users/7a305088-b8fa-4285-afec-af9d6dc2ef13'}
asctime: 2023-09-08 08:42:24,492

I suppose that we are sending CREATE on DELETE user events, or the user is not available because it's just created (which I doubt)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant