Trim content versions job logs error

Found in

EPiServer.CMS.Core 11.3.3

Fixed in

EPiServer.CMS.Core 11.4.0

Created

Feb 27, 2018

Updated

Mar 02, 2018

Area

CMS Core

State

Closed, Fixed and tested


Description

Steps to reproduce

  1. Run the "Trim content versions" job.
  2. View the log files.

Expected: No errors in logs.
Actual: You get the error below.

NOTE: There is nothing wrong with the behavior of the job. The problem is if there are no versions to trim, you get this error message in the log, since a counter becomes NULL instead of 0. There is no error message if there are versions to trim.

2018-02-27 15:41:12,727 [11] ERROR EPiServer.Util.Internal.TrimContentVersionsJob: Provider with key '' throwed exception when calling IContentVersionRepositoryEx.ListObsolete
System.InvalidCastException: Object cannot be cast from DBNull to other types.
   at System.DBNull.System.IConvertible.ToInt32(IFormatProvider provider)
   at System.Convert.ToInt32(Object value)
   at EPiServer.DataAccess.Internal.ContentVersionDB.<>c__DisplayClass5_0.<ListObsoleteVersions>b__0() in E:\BuildAgent\work\d8a53ffc288aa397\src\EPiServer\DataAccess\Internal\ContentVersionDB.cs:line 102
   at EPiServer.Data.Providers.Internal.SqlDatabaseExecutor.<>c__DisplayClass31_0`1.<Execute>b__0() in E:\BuildAgent\work\d8a53ffc288aa397\src\EPiServer.Data\Providers\Internal\SqlDatabaseExecutor.cs:line 197
   at EPiServer.Data.Providers.SqlTransientErrorsRetryPolicy.Execute[TResult](Func`1 method) in E:\BuildAgent\work\d8a53ffc288aa397\src\EPiServer.Data\Providers\SqlTransientErrorsRetryPolicy.cs:line 72
   at EPiServer.Data.Providers.Internal.SqlDatabaseExecutor.Execute[TResult](Func`1 action) in E:\BuildAgent\work\d8a53ffc288aa397\src\EPiServer.Data\Providers\Internal\SqlDatabaseExecutor.cs:line 192
   at EPiServer.DataAccess.Internal.ContentVersionDB.ListObsoleteVersions(Int32 maxPreviouslyPublishedVersions, Int32 maxResultCount, Int32& totalCount) in E:\BuildAgent\work\d8a53ffc288aa397\src\EPiServer\DataAccess\Internal\ContentVersionDB.cs:line 85
   at EPiServer.DataAbstraction.Internal.DefaultContentVersionRepository.ListObsolete(Int32 maxRows, Int32& totalCount) in E:\BuildAgent\work\d8a53ffc288aa397\src\EPiServer\DataAbstraction\Internal\DefaultContentVersionRepository.cs:line 268
   at EPiServer.Util.Internal.TrimContentVersionsJob.<>c__DisplayClass15_1.<Execute>b__2() in E:\BuildAgent\work\d8a53ffc288aa397\src\EPiServer\Util\Internal\TrimContentVersionsJob.cs:line 70
   at EPiServer.Util.Internal.TrimContentVersionsJob.ExecuteInTryCatch(Func`1 failureAction, Action action) in E:\BuildAgent\work\d8a53ffc288aa397\src\EPiServer\Util\Internal\TrimContentVersionsJob.cs:line 132
System.InvalidCastException: Object cannot be cast from DBNull to other types.
   at System.DBNull.System.IConvertible.ToInt32(IFormatProvider provider)
   at System.Convert.ToInt32(Object value)
   at EPiServer.DataAccess.Internal.ContentVersionDB.<>c__DisplayClass5_0.<ListObsoleteVersions>b__0() in E:\BuildAgent\work\d8a53ffc288aa397\src\EPiServer\DataAccess\Internal\ContentVersionDB.cs:line 102
   at EPiServer.Data.Providers.Internal.SqlDatabaseExecutor.<>c__DisplayClass31_0`1.<Execute>b__0() in E:\BuildAgent\work\d8a53ffc288aa397\src\EPiServer.Data\Providers\Internal\SqlDatabaseExecutor.cs:line 197
   at EPiServer.Data.Providers.SqlTransientErrorsRetryPolicy.Execute[TResult](Func`1 method) in E:\BuildAgent\work\d8a53ffc288aa397\src\EPiServer.Data\Providers\SqlTransientErrorsRetryPolicy.cs:line 72
   at EPiServer.Data.Providers.Internal.SqlDatabaseExecutor.Execute[TResult](Func`1 action) in E:\BuildAgent\work\d8a53ffc288aa397\src\EPiServer.Data\Providers\Internal\SqlDatabaseExecutor.cs:line 192
   at EPiServer.DataAccess.Internal.ContentVersionDB.ListObsoleteVersions(Int32 maxPreviouslyPublishedVersions, Int32 maxResultCount, Int32& totalCount) in E:\BuildAgent\work\d8a53ffc288aa397\src\EPiServer\DataAccess\Internal\ContentVersionDB.cs:line 85
   at EPiServer.DataAbstraction.Internal.DefaultContentVersionRepository.ListObsolete(Int32 maxRows, Int32& totalCount) in E:\BuildAgent\work\d8a53ffc288aa397\src\EPiServer\DataAbstraction\Internal\DefaultContentVersionRepository.cs:line 268
   at EPiServer.Util.Internal.TrimContentVersionsJob.<>c__DisplayClass15_1.<Execute>b__2() in E:\BuildAgent\work\d8a53ffc288aa397\src\EPiServer\Util\Internal\TrimContentVersionsJob.cs:line 70
   at EPiServer.Util.Internal.TrimContentVersionsJob.ExecuteInTryCatch(Func`1 failureAction, Action action) in E:\BuildAgent\work\d8a53ffc288aa397\src\EPiServer\Util\Internal\TrimContentVersionsJob.cs:line 132