Currently the API fails without sufficient user feedback if a user is logged in through Keycloak but does not have a CWMS account. This should theoretically not occur once automatic CWMS account creation via keycloak is enabled in all environments, but ideally some manner of feedback would be provided as a failsafe.
2026-03-09T18:57:11.955Z
File "/code/cwms_batch_events/core/auth/user/dependencies.py", line 32, in get_current_user_keycloak
2026-03-09T18:57:11.955Z
cda_user = get_user_profile(token)
2026-03-09T18:57:11.955Z
File "/code/cwms_batch_events/core/auth/user/roles.py", line 15, in get_user_profile
2026-03-09T18:57:11.955Z
profile = CdaUserProfile(**response.json())
2026-03-09T18:57:11.955Z
File "/usr/local/lib/python3.13/site-packages/pydantic/main.py", line 250, in __init__
2026-03-09T18:57:11.955Z
validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
2026-03-09T18:57:11.955Z
pydantic_core._pydantic_core.ValidationError: 4 validation errors for CdaUserProfile
2026-03-09T18:57:11.955Z
user-name
2026-03-09T18:57:11.955Z
Field required [type=missing, input_value={'message': 'Invalid User...t error', 'details': {}}, input_type=dict]
2026-03-09T18:57:11.955Z
For further information visit https://errors.pydantic.dev/2.12/v/missing
2026-03-09T18:57:11.955Z
principal
2026-03-09T18:57:11.955Z
Field required [type=missing, input_value={'message': 'Invalid User...t error', 'details': {}}, input_type=dict]
2026-03-09T18:57:11.955Z
For further information visit https://errors.pydantic.dev/2.12/v/missing
2026-03-09T18:57:11.955Z
cac-auth
2026-03-09T18:57:11.955Z
Field required [type=missing, input_value={'message': 'Invalid User...t error', 'details': {}}, input_type=dict]
2026-03-09T18:57:11.955Z
For further information visit https://errors.pydantic.dev/2.12/v/missing
2026-03-09T18:57:11.955Z
roles
2026-03-09T18:57:11.955Z
Field required [type=missing, input_value={'message': 'Invalid User...t error', 'details': {}}, input_type=dict]
2026-03-09T18:57:11.955Z
For further information visit https://errors.pydantic.dev/2.12/v/missing
Currently the API fails without sufficient user feedback if a user is logged in through Keycloak but does not have a CWMS account. This should theoretically not occur once automatic CWMS account creation via keycloak is enabled in all environments, but ideally some manner of feedback would be provided as a failsafe.