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

edge-alpine DB fails with an HEIC image for media_entity.metadataSizeWidth constraint #877

Closed
malavolti opened this issue Apr 5, 2024 · 20 comments

Comments

@malavolti
Copy link


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)
@grasdk
Copy link
Contributor

grasdk commented Apr 5, 2024

@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/)?

@malavolti
Copy link
Author

@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! 😊

@grasdk
Copy link
Contributor

grasdk commented Apr 6, 2024

@malavolti Hey again

I upgraded the image-size version in #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/ ?

@malavolti
Copy link
Author

@malavolti Hey again

I upgraded the image-size version in #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! 😊

@grasdk
Copy link
Contributor

grasdk commented Apr 13, 2024

@malavolti If you have the opportunity to install the latest edge-version. The issue should be resolved by that. Otherwise, please let me know ;)

@malavolti
Copy link
Author

I'll try as soon as possible! 😊 Thank you for all!

@bpatrik
Copy link
Owner

bpatrik commented Apr 14, 2024

NOTE: builds are failing in the last few days(weeks):
kép

So edge might not have the new fix-feature.

@grasdk
Copy link
Contributor

grasdk commented May 12, 2024

@bpatrik I think this is merged, so should probably be added to the "Next (probably v2.5)" milestone?

@bpatrik
Copy link
Owner

bpatrik commented May 15, 2024

Can someone confirm that the original issue was fixed?

@bpatrik bpatrik added the bug label May 15, 2024
@bpatrik bpatrik added this to the Next (probably v2.5) milestone May 15, 2024
@grasdk
Copy link
Contributor

grasdk commented May 16, 2024

Maybe @malavolti is still around to test latest edge build?

@malavolti
Copy link
Author

malavolti commented May 16, 2024

Dear @grasdk I've test the only the image that I shared with you in the past and the latest edge build fails with the same error of the issue I have opened in April.

2024-01-28_13.43.14.heic.txt

5/16/2024, 10:19:52 PM[INFO_][server] running diagnostics...
5/16/2024, 10:19:52 PM[INFO_][SQLConnection] Updating database scheme
5/16/2024, 10:19:52 PM[WARN_][ConfigDiagnostics] Jobs error. Resetting to default for now to let the app start up. Please adjust the config properly. Error: Unknown Job :Thumbnail Generation
5/16/2024, 10:19:52 PM[INFO_][JobManager] Running job schedules
5/16/2024, 10:19:52 PM[INFO_][server] Listening on port 80
QueryFailedError: SqliteError: NOT NULL constraint failed: media_entity.metadataSizeWidth
    at BetterSqlite3QueryRunner.query (/app/node_modules/typeorm/driver/better-sqlite3/BetterSqlite3QueryRunner.js:103:19)
    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:400:20)
    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, ?, ?, 1, 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 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:400:20)
      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'
}

Rename the file to get the image.heic

I've used the following docker-compose.yml and simply added heic and heif to supportedFormats into config.json file:

services:
  pigallery2:
    image: bpatrik/pigallery2:edge-alpine
    container_name: pigallery2
    environment:
      - NODE_ENV=production # set to 'debug' for full debug logging
      # - NODE_OPTIONS=--enable-source-maps # enable source map support on the backend for development
    volumes:
      - "./config:/app/data/config"
      - "./db-data:/app/data/db"
      - "./images:/app/data/images:rw"
      - "./tmp:/app/data/tmp"
    ports:
      - "85:80"
    restart: always

Thank you so much!
Marco

@grasdk
Copy link
Contributor

grasdk commented May 17, 2024

Hey @malavolti

Thank you for the input. Can you show the version of pigallery (click settings, hover over the app-version):
image

  • mine is in Danish locale.

@malavolti
Copy link
Author

Hey @malavolti

Thank you for the input. Can you show the version of pigallery (click settings, hover over the app-version):
image

  • mine is in Danish locale.

IMG_20240517_140856.jpg

@grasdk
Copy link
Contributor

grasdk commented May 17, 2024

I see the build date is 5th of april. Before the fix. You may need to clear the edge build image from your docker installation to force an update.

@malavolti
Copy link
Author

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. :(

@grasdk
Copy link
Contributor

grasdk commented May 25, 2024

@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: image-size/image-size#403
@bpatrik should we raise an issue here for pigallery "HEIC image size reported wrongly"? with a description linking to the above bug-report?

@bpatrik
Copy link
Owner

bpatrik commented Jun 28, 2024

Yeah we should track the HEIC image size issue somewhere.

@grasdk
Copy link
Contributor

grasdk commented Jun 29, 2024

@bpatrik ok, done: #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?

@malavolti
Copy link
Author

@bpatrik ok, done: #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?

Yes, sure. I agree. Thank you for all! 😊

@grasdk
Copy link
Contributor

grasdk commented Jun 29, 2024

@malavolti thank you too. To think out in open issues, I would suggest closing the issue if you have access to that. Otherwise maybe @bpatrik can do it ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants