UserRegistrationProvider crashes with REGISTER_ERROR

I am trying to write keycloak user id to external database on registration, but keycloak crashes even without database call. Storage provider itself works fine, is registered in keycloak and etc. Problem is with storing new user locally to keycloak.

addUser code is already simplified to bare minimum:

    public UserModel addUser(RealmModel realm, String username) {
        String uuid = UUID.randomUUID().toString();
        UserAdapter adapter = new UserAdapter(


        return adapter;

I just create UserAdapter, set my own generated UUID and return it like it’s done in many guides/code examples.

UserAdapter is:

public class UserAdapter extends AbstractUserAdapterFederatedStorage {
    protected String keycloakId;
    protected String username;

    public UserAdapter(KeycloakSession session, RealmModel realm, ComponentModel storageProviderModel, String uid) {
        super(session, realm, storageProviderModel);
        keycloakId = StorageId.keycloakId(storageProviderModel, uid);

    public String getUsername() {
        return this.username;

    public void setUsername(String username) {
        this.username = username;

    public String getId() {
        return keycloakId;

But on registration i get those errors from keycloak:

  1. WARN [] (default task-2) KC-SERVICES0013: Failed authentication: java.lang.RuntimeException: No user model provided for persisting changes
  2. WARN [] (default task-2) type=LOGIN_ERROR, realmId=product, clientId=spa, userId=null, ipAddress=, error=invalid_user_credentials, auth_method=openid-connect, redirect_uri=http://product.test/, authSessionParentId=3ccd3825-8ba1-4d26-8a00-bdfb968f442c, authSessionTabId=CchD1Kp-5Lo

As i understand my UserAdapter is faulty, and sure login fails after user store failed, but i can’t understand what’s wrong, i’ve already tried to set a break points with logs and till return from addUser everything looks kind of good?

What am i missing?