Truncation error when parsing KODI nfo files

Issue #992 invalid
xchrdw created an issue
I get the following exception when parsing my library with nfo files generated by kodi: "A truncation error was encountered trying to shrink VARCHAR '7900000' to length 5". The issue seems to be that Kodi stores ratings as
<episodedetails>
    ...
    <rating>7.900000</rating>
   ...
</episodedetails>
When I manually change the value to 7.9 Serviio parses it without error. It would be great if you could truncate the rating value before writing it to the database or fix it in other ways :)
2017-01-06 15:14:51,498 WARN  [MediaFileIndexer] Cannot update file XXX in
library because of an unexpected error. Message: Cannot update Video with id 21
org.serviio.db.dao.PersistenceException: Cannot update Video with id 21
        at org.serviio.library.dao.VideoDAOImpl.update(VideoDAOImpl.java:218)
        at org.serviio.library.dao.VideoDAOImpl.update(VideoDAOImpl.java:37)
        at org.serviio.library.local.service.VideoService.updateVideoInLibrary(VideoService.java:257)
        at org.serviio.library.local.indexing.MediaFileIndexer.updateMediaFile(MediaFileIndexer.java:150)
        at org.serviio.library.local.indexing.DefaultLibraryMonitor.fileUpdated(DefaultLibraryMonitor.java:65)
        at org.serviio.library.local.indexing.pipe.PipeManager$PipeProcessingConsumer.lambda$run$27(PipeManager.java:175)
        at java.util.Optional.ifPresent(Optional.java:159)
        at org.serviio.library.local.indexing.pipe.PipeManager$PipeProcessingConsumer.run(PipeManager.java:169)
        at java.lang.Thread.run(Thread.java:745)
Caused by: java.sql.SQLDataException: A truncation error was encountered trying to shrink VARCHAR '7900000' to length 5.
        at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source)
        at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source)
        at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(Unknown Source)
        at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(Unknown Source)
        at org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown Source)
        at org.apache.derby.impl.jdbc.ConnectionChild.handleException(Unknown Source)
        at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(Unknown Source)
        at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeStatement(Unknown Source)
        at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeLargeUpdate(Unknown Source)
        at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeUpdate(Unknown Source)
        at org.serviio.library.dao.VideoDAOImpl.update(VideoDAOImpl.java:216)
        ... 8 more
Caused by: ERROR 22001: A truncation error was encountered trying to shrink VARCHAR '7900000' to length 5.
        at org.apache.derby.iapi.error.StandardException.newException(Unknown Source)
        at org.apache.derby.iapi.error.StandardException.newException(Unknown Source)
        at org.apache.derby.iapi.types.SQLChar.hasNonBlankChars(Unknown Source)
        at org.apache.derby.iapi.types.SQLVarchar.normalize(Unknown Source)
        at org.apache.derby.iapi.types.SQLVarchar.normalize(Unknown Source)
        at org.apache.derby.iapi.types.DataTypeDescriptor.normalize(Unknown Source)
        at org.apache.derby.impl.sql.execute.NormalizeResultSet.normalizeColumn(Unknown Source)
        at org.apache.derby.impl.sql.execute.NormalizeResultSet.normalizeRow(Unknown Source)
        at org.apache.derby.impl.sql.execute.NormalizeResultSet.getNextRowCore(Unknown Source)
        at org.apache.derby.impl.sql.execute.DMLWriteResultSet.getNextRowCore(Unknown Source)
        at org.apache.derby.impl.sql.execute.UpdateResultSet.getNextRowCore(Unknown Source)
        at org.apache.derby.impl.sql.execute.UpdateResultSet.collectAffectedRows(Unknown Source)
        at org.apache.derby.impl.sql.execute.UpdateResultSet.open(Unknown Source)
        at org.apache.derby.impl.sql.GenericPreparedStatement.executeStmt(Unknown Source)
        at org.apache.derby.impl.sql.GenericPreparedStatement.execute(Unknown Source)
        ... 13 more

Comments (6)

  1. xchrdw reporter
    Thanks for the fast response! I found another problematic rating from kodi in my library that isn't solved by just cutting off zeroes: <rating>8.100001</rating>
  2. xchrdw reporter
    I just tried it again using Kodi 17.1 and Serviio 1.8. Kodi still exports nfo files with many zeros but the import seems to work fine. Thanks!
  3. Log in to comment