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

MemberTypeHandler import fail error (default member property type duplicate key) #169

Closed
lindeberg opened this issue Oct 6, 2020 · 3 comments
Labels
patch-release this issue contains a patch build release to resolve the issue. release/8.7.2

Comments

@lindeberg
Copy link

Describe the bug
When having two different member types I get an error when importing one of the member types to another environment.

"memberTypeHandler": Import Failed : "System.Data.SqlClient.SqlException (0x80131904): Cannot insert duplicate key row in object 'dbo.cmsPropertyType' with unique index 'IX_cmsPropertyTypeUniqueID'. The duplicate key value is (e79dccfb-0000-0000-0000-000000000000). The statement has been terminated. at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData() at System.Data.SqlClient.SqlDataReader.get_MetaData() at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption, Boolean shouldCacheForAlwaysEncrypted) at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) at System.Data.SqlClient.SqlCommand.ExecuteScalar() at StackExchange.Profiling.Data.ProfiledDbCommand.ExecuteScalar() in C:\projects\dotnet\src\MiniProfiler.Shared\Data\ProfiledDbCommand.cs:line 334 at Umbraco.Core.Persistence.FaultHandling.FaultHandlingDbCommand.b__32_0() in D:\a\1\s\src\Umbraco.Core\Persistence\FaultHandling\RetryDbConnection.cs:line 214 at Umbraco.Core.Persistence.FaultHandling.FaultHandlingDbCommand.<>c__DisplayClass33_01.<Execute>b__0() in D:\a\1\s\src\Umbraco.Core\Persistence\FaultHandling\RetryDbConnection.cs:line 222 at Umbraco.Core.Persistence.FaultHandling.RetryPolicy.ExecuteAction[TResult](Func1 func) in D:\a\1\s\src\Umbraco.Core\Persistence\FaultHandling\RetryPolicy.cs:line 172 at Umbraco.Core.Persistence.FaultHandling.FaultHandlingDbCommand.Execute[T](Func1 f) in D:\a\1\s\src\Umbraco.Core\Persistence\FaultHandling\RetryDbConnection.cs:line 219 at Umbraco.Core.Persistence.FaultHandling.FaultHandlingDbCommand.ExecuteScalar() in D:\a\1\s\src\Umbraco.Core\Persistence\FaultHandling\RetryDbConnection.cs:line 214 at NPoco.Database.ExecuteScalarHelper(DbCommand cmd) at NPoco.DatabaseTypes.SqlServerDatabaseType.ExecuteInsert[T](Database db, DbCommand cmd, String primaryKeyName, Boolean useOutputClause, T poco, Object[] args) at NPoco.Database.InsertImp[T](PocoData pocoData, String tableName, String primaryKeyName, Boolean autoIncrement, T poco) at NPoco.Database.Insert[T](String tableName, String primaryKeyName, Boolean autoIncrement, T poco) at NPoco.Database.Insert[T](T poco) at Umbraco.Core.Persistence.Repositories.Implement.ContentTypeRepositoryBase1.PersistNewBaseContentType(IContentTypeComposition entity) in D:\a\1\s\src\Umbraco.Core\Persistence\Repositories\Implement\ContentTypeRepositoryBase.cs:line 207 at Umbraco.Core.Persistence.Repositories.Implement.MemberTypeRepository.PersistNewItem(IMemberType entity) in D:\a\1\s\src\Umbraco.Core\Persistence\Repositories\Implement\MemberTypeRepository.cs:line 153 at Umbraco.Core.Cache.FullDataSetRepositoryCachePolicy2.Create(TEntity entity, Action1 persistNew) in D:\a\1\s\src\Umbraco.Core\Cache\FullDataSetRepositoryCachePolicy.cs:line 73 at Umbraco.Core.Persistence.Repositories.Implement.RepositoryBase2.Save(TEntity entity) in D:\a\1\s\src\Umbraco.Core\Persistence\Repositories\Implement\RepositoryBaseOfTIdTEntity.cs:line 138 at Umbraco.Core.Services.Implement.ContentTypeServiceBase3.Save(TItem item, Int32 userId) in D:\a\1\s\src\Umbraco.Core\Services\Implement\ContentTypeServiceBaseOfTRepositoryTItemTService.cs:line 423 at uSync8.Core.Serialization.Serializers.ContentTypeBaseSerializer1.SaveItem(TObject item) at uSync8.Core.Serialization.SyncSerializerRoot1.Deserialize(XElement node, SyncSerializerOptions options) at uSync8.BackOffice.SyncHandlers.SyncHandlerRoot2.DeserializeItem(XElement node, SyncSerializerOptions options) at uSync8.BackOffice.SyncHandlers.SyncHandlerRoot2.Import(String filePath, HandlerSettings config, SerializerFlags flags) ClientConnectionId:0b7f6797-b69a-4320-988d-c65c25c40ec4 Error Number:2601,State:1,Class:14"`

To Reproduce
Unfortunately I didn't manage to reproduce

Expected behavior
I do not expect an error.

Screenshots
image

Desktop (please complete the following information):

  • Umbraco Version: 8.6.4
  • uSync Version: 8.7.0.1
  • OS: Windows 10

Additional context
It works if I remove the default member properties from the member type config file.
The property that is colliding now is 'IsApproved'. But if removing that property from the config file, the next default member type property gets the same error.
image

@lindeberg lindeberg changed the title MemberTypeHandler import fail error (default member property duplicate key) MemberTypeHandler import fail error (default member property type duplicate key) Oct 6, 2020
@KevinJump
Copy link
Owner

Hi, we just missed the new release with this 😞

The issue is that for properties in member types the GUID doesn't really get used and as a result Umbraco makes it up when reporting it via the API (so it changes a lot) - uSync generates a pseudo GUID based on the property alias. but as you have discovered if the property alias is the same between member types (which it will be because well know properties are always there!) then you get a clash.

The workaround if you are stuck is to go into the company.config file for the company member type and add a digit to the guid. (for example change it from e79dccfb-0000-0000-0000-000000000000 to e79dccfb-0000-0000-0000-000000000001) - not ideal but your import will work.

fix will be in the Next patch release of uSync (v8.7.2)

@KevinJump
Copy link
Owner

Attached nuget package. (unzip it first) - has this patch in.

uSync.Core.8.7.2-build-01.zip

@KevinJump KevinJump added the patch-release this issue contains a patch build release to resolve the issue. label Oct 6, 2020
@lindeberg
Copy link
Author

Unfortunately the issue remains for me after the latest update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
patch-release this issue contains a patch build release to resolve the issue. release/8.7.2
Projects
None yet
Development

No branches or pull requests

2 participants