MetaCell / MetaCell/cloud-harness
User not found while syncing users with django
- Dominant language
- Python
- Stars
- 19
- Forks
- 5
- Avg merge
- 3d 18h
- Merged PRs (30d)
- 3
Description
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:
```
{'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)
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with cloudharness_django/services/events.py at event_handler line 36 and compare the logged CREATE event with cloudharness/auth/keycloak.py get_user around lines 440-442. Trace the event through cloudharness/events/client.py _consume_task and reproduce the reported 404; done means the newly created user's sync no longer raises UserNotFound.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- django, python
- Domain
- authentication, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 32/100