Skip to content

MediaSelectionControl for required field gives potential errors and wrong configurated field #582

@roeldeb

Description

@roeldeb

Brief bug description

When a field with MediaSelectionControl in K13 is set as required, but the state of that field has a missing item in the media library (broken image showing), the imported PageType has:

  • Imported field is of type "Pages and reusable content"

  • Field set to required, but not possible turning it off (this should be not possible in XbyK)

  • Imported content is done partially, the contentitem/webpageitem tables have records, but the pagetype record itself is missing, because of the error not accepting null (table WH_Persoon in example error below)

  • Opening the page (it does show up in contenttree) gives a 500

What went wrong?

Output logs

Migration.Tool.Source.Mappers.ContentItemMapper[0] Error while migrating field 'PersoonFoto' value ~/getmedia/e5d9f6d9-2a25-47ee-9293-8cfd77b34f19/Andy-SSC.jpg?width=4256&height=2832&ext=.jpg
10:37:14.849 fail: Kentico.Xperience.UMT.Services.Importer[0] Entity persistence failed System.Exception: 
 [DataConnection.HandleError]: 
 
 Query: 
 INSERT INTO WH_Persoon ([ContentItemDataCommonDataID], [ContentItemDataGUID], [MetadataTitle], [MetadataDescription], [MetadataColor], [MetadataImage], [MetadataNoIndex], [MetadataSearchContent], [MetadataContentOwner], [MetadataContentEditor], [SearchWords], [PersoonVoornaam], [PersoonTussenvoegsel], [PersoonAchternaam], [PersoonPrefix], [PersoonSuffix], [PersoonFunctie], [PersoonFoto], [PersoonMobielNummer], [PersoonMobielNummerDisplay], [PersoonVastNummer], [PersoonEmailAdres], [PersoonContactFormulierURL], [PersoonLinkedInURLCustomName], [PersoonLinkedInURL], [PersoonFacebookURL], [PersoonInstagramURL], [PersoonHasDetailPage], [PersoonDescription], [PersoonEmplyID], [DocumentName1]) 
 VALUES (@ContentItemDataCommonDataID, @ContentItemDataGUID, @MetadataTitle, @MetadataDescription, @MetadataColor, @MetadataImage, @MetadataNoIndex, @MetadataSearchContent, @MetadataContentOwner, @MetadataContentEditor, @SearchWords, @PersoonVoornaam, @PersoonTussenvoegsel, @PersoonAchternaam, @PersoonPrefix, @PersoonSuffix, @PersoonFunctie, @PersoonFoto, @PersoonMobielNummer, @PersoonMobielNummerDisplay, @PersoonVastNummer, @PersoonEmailAdres, @PersoonContactFormulierURL, @PersoonLinkedInURLCustomName, @PersoonLinkedInURL, @PersoonFacebookURL, @PersoonInstagramURL, @PersoonHasDetailPage, @PersoonDescription, @PersoonEmplyID, @DocumentName1);
 
 SELECT SCOPE_IDENTITY() AS [ID]
 
 Caused exception: 
 Cannot insert the value NULL into column 'PersoonFoto', table 'TargetDB.dbo.WH_Persoon'; column does not allow nulls. INSERT fails. The statement has been terminated.
   ---> Microsoft.Data.SqlClient.SqlException (0x80131904): Cannot insert the value NULL into column 'PersoonFoto', table 'TargetDB.dbo.WH_Persoon'; column does not allow nulls. INSERT fails. The statement has been terminated.    at Microsoft.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, SqlCommand command, Boolean callerHasConnectionLock, Boolean asyncClose)    at Microsoft.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)    at Microsoft.Data.SqlClient.SqlDataReader.TryConsumeMetaData()    at Microsoft.Data.SqlClient.SqlDataReader.get_MetaData()    at Microsoft.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption, Boolean shouldCacheForAlwaysEncrypted)    at Microsoft.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean isAsync, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest)    at Microsoft.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry, String method)    at Microsoft.Data.SqlClient.SqlCommand.ExecuteScalar()    at CMS.DataEngine.AbstractDataConnection.ExecuteScalar(String queryText, QueryDataParameters queryParams, QueryTypeEnum queryType, Boolean requiresTransaction) ClientConnectionId:bc268dda-036e-4a3d-b5d3-b6062f291d8f Error Number:515,State:2,Class:16    --- End of inner exception stack trace ---    at CMS.DataEngine.AbstractDataConnection.HandleError(String queryText, Exception ex)    at CMS.DataEngine.AbstractDataConnection.ExecuteScalar(String queryText, QueryDataParameters queryParams, QueryTypeEnum queryType, Boolean requiresTransaction)    at CMS.DataEngine.GeneralConnection.ExecuteScalar(QueryParameters query)    at CMS.DataEngine.DataQueryBase`1.GetScalarResult()    at CMS.DataEngine.DataQueryBase`1.GetScalarResult[T](T defaultValue)    at CMS.DataEngine.DataClassDataSqlStore.InsertSyncOrAsync(Boolean useAsync, IDataClass dataClass, Boolean initializeId, CancellationToken cancellationToken)    at CMS.DataEngine.AbstractInfoBase`1.InsertDataInternal()    at CMS.DataEngine.AbstractInfoBase`1.InsertDataSyncOrAsync(Boolean useAsync, CancellationToken cancellationToken)    at CMS.DataEngine.AbstractInfoBase`1.InsertData()    at CMS.DataEngine.AbstractInfoProvider`3.WithEvent[TBeforeEvent,TAfterEvent](Action action, IEnumerable`1 beforeEventHandlers, TBeforeEvent beforeEvent, IEnumerable`1 afterEventHandlers, Func`1 afterEventFactory)    at CMS.DataEngine.AbstractInfoProvider`3.SetInfoSyncOrAsync(Boolean useAsync, TInfo info, CancellationToken cancellationToken)    at CMS.DataEngine.AbstractInfoProvider`3.SetInfo(TInfo info)    at Kentico.Xperience.UMT.ProviderProxy.ContentItemDataProxy.Save(BaseInfo info, IUmtModel model)    at Kentico.Xperience.UMT.Services.Importer.ImportObject(IUmtModel model, IProviderProxyContext providerProxyContext)
10:37:14.850 fail: Migration.Tool.Source.Handlers.MigratePagesCommandHandler[0] Failed to import: System.Exception: 
 [DataConnection.HandleError]: 

Expected behavior

  • The field created in XbyK should never be Required
  • If it is required in K13, the created field should have the MinimumItems and MaximumItems set to 1
  • My guess is that MaximumItems should always be 1

Test environment

  • Version 4.1.1

Screenshots

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions