pigallery2: edge-alpine DB fails with an HEIC image for media_entity.metadataSizeWidth constraint


Describe the bug

If I try to load this image, I receive the following error on SQLLite DB and no images are loaded on my piGallery2.

Photo/video (optional) that causes the bug

https://we.tl/t-pEdQHVDG4W

Server logs (optional)

QueryFailedError: SqliteError: NOT NULL constraint failed: media_entity.metadataSizeWidth
    at BetterSqlite3QueryRunner.query (/app/node_modules/typeorm/driver/better-sqlite3/BetterSqlite3QueryRunner.js:103:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async InsertQueryBuilder.execute (/app/node_modules/typeorm/query-builder/InsertQueryBuilder.js:106:33)
    at async SubjectExecutor.executeInsertOperations (/app/node_modules/typeorm/persistence/SubjectExecutor.js:260:42)
    at async SubjectExecutor.execute (/app/node_modules/typeorm/persistence/SubjectExecutor.js:92:9)
    at async EntityPersistExecutor.execute (/app/node_modules/typeorm/persistence/EntityPersistExecutor.js:148:21)
    at async IndexingManager.saveChunk (/app/src/backend/model/database/IndexingManager.js:404:32)
    at async IndexingManager.saveMedia (/app/src/backend/model/database/IndexingManager.js:329:9)
    at async IndexingManager.saveToDB (/app/src/backend/model/database/IndexingManager.js:95:13)
    at async IndexingManager.queueForSave (/app/src/backend/model/database/IndexingManager.js:128:17) {
  query: 'INSERT INTO "media_entity"("id", "name", "type", "directoryId", "metadataCaption", "metadataTitle", "metadataCreationdate", "metadataCreationdateoffset", "metadataFilesize", "metadataKeywords", "metadataRating", "metadataFaces", "metadataPersons", "metadataPersonslength", "metadataBitrate", "metadataDuration", "metadataSizeWidth", "metadataSizeHeight", "metadataCameraDataIso", "metadataCameraDataModel", "metadataCameraDataMake", "metadataCameraDataFstop", "metadataCameraDataExposure", "metadataCameraDataFocallength", "metadataCameraDataLens", "metadataPositionDataCountry", "metadataPositionDataState", "metadataPositionDataCity", "metadataPositionDataGPSDataLatitude", "metadataPositionDataGPSDataLongitude") VALUES (NULL, ?, ?, 344, NULL, NULL, 1706438594000, 180, 2158564, NULL, NULL, NULL, NULL, 0, NULL, NULL, ?, ?, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 9.061331, 38.761711)',
  parameters: [ '2024-01-28_13.43.14.heic', 'PhotoEntity', null, null ],
  driverError: SqliteError: NOT NULL constraint failed: media_entity.metadataSizeWidth
      at BetterSqlite3QueryRunner.query (/app/node_modules/typeorm/driver/better-sqlite3/BetterSqlite3QueryRunner.js:85:38)
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
      at async InsertQueryBuilder.execute (/app/node_modules/typeorm/query-builder/InsertQueryBuilder.js:106:33)
      at async SubjectExecutor.executeInsertOperations (/app/node_modules/typeorm/persistence/SubjectExecutor.js:260:42)
      at async SubjectExecutor.execute (/app/node_modules/typeorm/persistence/SubjectExecutor.js:92:9)
      at async EntityPersistExecutor.execute (/app/node_modules/typeorm/persistence/EntityPersistExecutor.js:148:21)
      at async IndexingManager.saveChunk (/app/src/backend/model/database/IndexingManager.js:404:32)
      at async IndexingManager.saveMedia (/app/src/backend/model/database/IndexingManager.js:329:9)
      at async IndexingManager.saveToDB (/app/src/backend/model/database/IndexingManager.js:95:13)
      at async IndexingManager.queueForSave (/app/src/backend/model/database/IndexingManager.js:128:17) {
    code: 'SQLITE_CONSTRAINT_NOTNULL'
  },
  code: 'SQLITE_CONSTRAINT_NOTNULL'
}

Environment (please complete the following information):

  • OS: Server runs on Linux Debian 12 with Docker, FireFox browser on Linux Debian 12
  • Browser: FireFox 122.0.1

Used app version:

  • docker-edge (alpine)

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 20 (13 by maintainers)

Most upvoted comments

@bpatrik ok, done: https://github.com/bpatrik/pigallery2/issues/918 . I’ll make a more comprehensive description if you would like. For now I just link to the issue with the image-size library.

@malavolti do you agree that we can close this issue, given that there is another issue now for tracking the 512x512-problem?

Yeah we should track the HEIC image size issue somewhere.

@malavolti thanks. So the issue here is resolved.

But there is a new issue. However, it’s about the image-size library. I reported the bug over there: https://github.com/image-size/image-size/issues/403 @bpatrik should we raise an issue here for pigallery “HEIC image size reported wrongly”? with a description linking to the above bug-report?

IMG_20240524_143140

I can say that with this version I can see the HEIC images, but all of them are compressed to the resolution of 512x512. 😦

@malavolti Hey again

I upgraded the image-size version in https://github.com/bpatrik/pigallery2/pull/879, but I actually found out that it incorrectly reports the dimensions of your photo as 512x512. It fixes the problem with null in pigallery, but it’s still not correct.

Would you mind me submitting the photo in a bug-report over at https://github.com/image-size/ ?

Yes, no problem. Thank you! 😊

@malavolti I found the problem and a solution. May I use the picture you provided as test-material in the project (adding it to /test/backend/assets/)?

Yes, sure! 😊