User directory synchronization fails with the exception "java.lang.IllegalArgumentException: Value <STRING> exceeds maximum allowed length of 255 characters" in Bitbucket Data Center
Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.
Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Summary
User directory synchronization fails because there is at least one account whose user name attribute has more than 255 characters.
Environment
Bitbucket Server or Data Center instance configured with a "Connector" type external user directory.
Diagnosis
The atlassian-bitbucket.log
shows the error:
2023-02-19 20:01:12,565 ERROR [Caesium-1-4] c.a.c.d.DbCachingRemoteDirectory Exception occured when performing full synchronization
java.lang.IllegalArgumentException: Value 'A very long string that contains more than 255 characters. A very long string that contains more than 255 characters. A very long string that contains more than 255 characters. A very long string that contains more than 255 characters A very long string that contains more than 255 characters.' exceeds maximum allowed length of 255 characters
at com.atlassian.crowd.util.InternalEntityUtils.validateLength(InternalEntityUtils.java:51)
at com.atlassian.crowd.model.user.InternalUser.setName(InternalUser.java:183)
at com.atlassian.crowd.model.user.InternalUser.renameTo(InternalUser.java:155)
at com.atlassian.crowd.dao.user.UserDAOHibernate.rename(UserDAOHibernate.java:412)
at com.atlassian.stash.internal.crowd.HibernateUserDao.rename(HibernateUserDao.java:253)
at com.atlassian.stash.internal.crowd.HibernateUserDao.rename(HibernateUserDao.java:74)
at com.atlassian.crowd.directory.AbstractInternalDirectory.forceRenameUser(AbstractInternalDirectory.java:584)
at com.atlassian.crowd.directory.DbCachingRemoteChangeOperations.updateUsers(DbCachingRemoteChangeOperations.java:284)
at com.atlassian.crowd.directory.DirectoryCacheImplUsingChangeOperations.addOrUpdateCachedUsers(DirectoryCacheImplUsingChangeOperations.java:58)
at com.atlassian.crowd.directory.synchronisation.cache.UsnChangedCacheRefresher.synchroniseAllUsers(UsnChangedCacheRefresher.java:202)
at com.atlassian.crowd.directory.synchronisation.cache.AbstractCacheRefresher.synchroniseAll(AbstractCacheRefresher.java:45)
at com.atlassian.crowd.directory.synchronisation.cache.UsnChangedCacheRefresher.synchroniseAll(UsnChangedCacheRefresher.java:174)
at com.atlassian.crowd.directory.DbCachingRemoteDirectory.synchroniseCache(DbCachingRemoteDirectory.java:1098)
at com.atlassian.crowd.manager.directory.DirectorySynchroniserImpl.lambda$synchronise$0(DirectorySynchroniserImpl.java:85)
at com.atlassian.crowd.audit.NoOpAuditLogContext.withAuditLogSource(NoOpAuditLogContext.java:17)
at com.atlassian.crowd.manager.directory.DirectorySynchroniserImpl.synchronise(DirectorySynchroniserImpl.java:83)
at com.atlassian.crowd.directory.DbCachingDirectoryPoller.pollChanges(DbCachingDirectoryPoller.java:48)
at com.atlassian.crowd.manager.directory.monitor.poller.DirectoryPollerJobRunner.runJob(DirectoryPollerJobRunner.java:92)
at com.atlassian.scheduler.core.JobLauncher.runJob(JobLauncher.java:134)
at com.atlassian.scheduler.core.JobLauncher.launchAndBuildResponse(JobLauncher.java:106)
at com.atlassian.scheduler.core.JobLauncher.launch(JobLauncher.java:90)
at com.atlassian.scheduler.caesium.impl.CaesiumSchedulerService.launchJob(CaesiumSchedulerService.java:435)
at com.atlassian.scheduler.caesium.impl.CaesiumSchedulerService.executeClusteredJob(CaesiumSchedulerService.java:430)
at com.atlassian.scheduler.caesium.impl.CaesiumSchedulerService.executeClusteredJobWithRecoveryGuard(CaesiumSchedulerService.java:454)
at com.atlassian.scheduler.caesium.impl.CaesiumSchedulerService.executeQueuedJob(CaesiumSchedulerService.java:382)
at com.atlassian.scheduler.caesium.impl.SchedulerQueueWorker.executeJob(SchedulerQueueWorker.java:66)
at com.atlassian.scheduler.caesium.impl.SchedulerQueueWorker.executeNextJob(SchedulerQueueWorker.java:60)
at com.atlassian.scheduler.caesium.impl.SchedulerQueueWorker.run(SchedulerQueueWorker.java:35)
at java.lang.Thread.run(Thread.java:745)
... 39 frames trimmed
Cause
There is a limit of 255 characters for usernames in Bitbucket.
If there is one or more accounts whose username exceeds this limit, directory synchronization fails due to the exception above.
Solution
First, check if the correct user directory attribute was selected as User Name Attribute in the directory configuration. You may have chosen the wrong attribute as the user name attribute.
To check:
- Go to:
Administration > User Directories
- Select and edit the external user directory
- Check the
User Name Attribute
underUser Schema Settings
If the User Name Attribute value is correct, check for any accounts in the user directory where the selected attribute has more than 255 characters. Update them so that the value is less than the 255 limit.
Related Links
The Difference Between Delegated and Connector LDAP User Directories