Unable to import photo due to error: "TypeError: e.trim is not a function"

I’ve noticed that some of my photos never appear in PS.
Upon investigation, they all have a common error message “TypeError: e.trim is not a function” as seen in the attached logs.

Expected Behavior

  1. I expect 2/2 photos to be imported and appear on the GUI.

Current Behavior

  1. Only 1 photo appears on the GUI instead of the expected two.

Steps to Reproduce

  1. Setup PS in Docker, on Windows. Note that it’s connected to my NAS via SMB, although I don’t think it’s related to the issue since I can repro the issue when running PS in Docker on my NAS locally.
  2. Add sample photos (one good and one that causes this bug) to the /pictures/ folder
  3. Launch PS in docker
  4. Open PS in browser
  5. Accept most default settings, using the Lite free version, and leave initial settings unchanged - except for disabling the ability to self-organise the photos
  6. Wait until I see good photo imported to check the logs

Environment

Operating system and version:

  • Win 11 + Docker
  • repro’s on NAS + Docker too

PhotoStructure edition: PhotoStructure for Docker
Version: 2.1.0-alpha.7
Plan: Lite
OS: Alpine Linux v3.16 on x64 (Docker)
Free memory: 32 GB / 34 GB
CPUs: 32 × 13th Gen Intel(R) Core™ i9-13900K

Attachments

See this Gist.

Sync logs

{"ts":1739702437226,"l":"warn","ctx":"Sentry","msg":"Failed to set up sentry","meta":"TypeError: Cannot read properties of undefined (reading 'init') at t.installSentry (/ps/app/bin/sync.js:9:884914); t.Service.setupErrorHandling (/ps/app/bin/sync.js:9:893928); t.Service._setup (/ps/app/bin/sync.js:9:892186)…t (/ps/app/bin/sync.js:9:890629)"}
{"ts":1739702437344,"l":"warn","ctx":"Library(/ps/library)","msg":"Library is on a remote volume. Setting forceLocalDbReplica to true."}
{"ts":1739702437344,"l":"warn","ctx":"Library(/ps/library)","msg":"Library previews are on a remote volume. Setting maxSyncFileJobsMax to 2."}
{"ts":1739702437475,"l":"warn","ctx":"StatsDbDir","msg":"deleting cache dir /ps/library/.photostructure/cache-1000/sync-state-2yya93pbhf"}
{"ts":1739702438823,"l":"warn","ctx":"async.Deferred(fs.readdir)","msg":".reject()","meta":"EACCES: permission denied, scandir '/root' at (missing stack)"}
{"ts":1739702438824,"l":"warn","ctx":"fs.Readdir","msg":"readdir() failed for /root","meta":"EACCES: permission denied, scandir '/root' at (missing stack)"}
{"ts":1739702438824,"l":"warn","ctx":"fs.Readdir","msg":"readdir() failed for /root","meta":"EACCES: permission denied, scandir '/root' at (missing stack)"}
{"ts":1739702443153,"l":"warn","ctx":"_updateAssetPreviews(1)","msg":"Failed to update previews. Un-showing asset 1","meta":"TypeError: e.trim is not a function at /ps/app/bin/sync.js:9:920608; Array.map (<anonymous>); /ps/app/bin/sync.js:9:920598; Array.map (<anonymous>); k (/ps/app/bin/sync.js:9:920568); x (/ps/app/bin/sync.js:9:921490); t.keywordTagFiles (/ps/app/bin/sync.js:9:921963); t.thenMap (/ps/app/bin/sync.js:9:842566); T (/ps/app/bin/sync.js:9:913281)"}
{"ts":1739702443158,"l":"warn","ctx":"AssetFileImporter(/pictures/Best of (3+ stars)/photo_that_cant_be_imported.jpg)","msg":"finished preview generation","meta":{"previewsFailed":true,"previewResult":{"id":1,"skipped":false,"error":"TypeError: e.trim is not a function"}}}
{"ts":1739702443159,"l":"warn","ctx":"SyncReport()","msg":"onProgress()","meta":{"path":"/pictures/Best of (3+ stars)/photo_that_cant_be_imported.jpg","state":"failed","assetId":1,"assetFileId":1,"uri":"psfile://2HiiFL2Mk/Best%20of%20%283%2B%20stars%29/photo_that_cant_be_imported.jpg","details":"TypeError: e.trim is not a function","from":"importFileToResult()","elapsedMs":2350,"url":"http://127.0.0.1:1787/asset/1"}}
{"ts":1739702443159,"l":"warn","ctx":"SyncService","msg":"#processFile() error result","meta":{"nativePath":"/pictures/Best of (3+ stars)/photo_that_cant_be_imported.jpg","result":{"path":"/pictures/Best of (3+ stars)/photo_that_cant_be_imported.jpg","state":"failed","assetId":1,"assetFileId":1,"uri":"psfile://2HiiFL2Mk/Best%20of%20%283%2B%20stars%29/photo_that_cant_be_imported.jpg","details":"TypeError: e.trim is not a function"},"retries":1}}

Sync report excerpt

ts,at,path,state,from,elapsedMs,details,url
1739702439808,2025-02-16T10:40:39.808Z,/pictures/,scanning,DirectoryIterator,,,
1739702439817,2025-02-16T10:40:39.817Z,/pictures/.uuid,rejected,DirectoryIterator,,not photo or video extension,
1739702439817,2025-02-16T10:40:39.817Z,/pictures/Best of (3+ stars)/,scanning,DirectoryIterator,,,
1739702439824,2025-02-16T10:40:39.824Z,/pictures/Best of (3+ stars)/Thumbs.db,rejected,DirectoryIterator,,not photo or video extension,
1739702439827,2025-02-16T10:40:39.827Z,/pictures/Best of (3+ stars)/photo_that_cant_be_imported.jpg,enqueued,AssetFileQueue,,,
1739702439827,2025-02-16T10:40:39.827Z,/pictures/Best of (3+ stars)/photo_that_works_fine.jpg,enqueued,AssetFileQueue,,,
1739702439837,2025-02-16T10:40:39.837Z,/pictures/Best of (3+ stars)/,scanned,DirectoryIterator,20,3/3 files and 0/0 directories,http://127.0.0.1:1787/tag/fs/2HiiFL2Mk/Best%2520of%2520%283%252B%2520stars%29
1739702439841,2025-02-16T10:40:39.841Z,/pictures/,scanned,DirectoryIterator,33,1/1 file and 1/1 directory,http://127.0.0.1:1787/tag/fs/2HiiFL2Mk
1739702440809,2025-02-16T10:40:40.809Z,/pictures/Best of (3+ stars)/photo_that_cant_be_imported.jpg,started,importFileToResult(),,,
1739702440810,2025-02-16T10:40:40.810Z,/pictures/Best of (3+ stars)/photo_that_works_fine.jpg,started,importFileToResult(),,,
1739702443159,2025-02-16T10:40:43.159Z,/pictures/Best of (3+ stars)/photo_that_cant_be_imported.jpg,failed,importFileToResult(),2350,TypeError: e.trim is not a function,http://127.0.0.1:1787/asset/1
1739702443159,2025-02-16T10:40:43.159Z,/pictures/Best of (3+ stars)/photo_that_cant_be_imported.jpg,started,importFileToResult(),,,
1739702443163,2025-02-16T10:40:43.163Z,/pictures/Best of (3+ stars)/photo_that_cant_be_imported.jpg,noop,importFileToResult(),4,,http://127.0.0.1:1787/asset/1
1739702443166,2025-02-16T10:40:43.166Z,/pictures/Best of (3+ stars)/photo_that_works_fine.jpg,started,importFileToResult(),,,
1739702443168,2025-02-16T10:40:43.168Z,/pictures/Best of (3+ stars)/photo_that_works_fine.jpg,noop,importFileToResult(),2,,http://127.0.0.1:1787/asset/2
1739702444280,2025-02-16T10:40:44.280Z,/pictures/Best of (3+ stars)/photo_that_works_fine.jpg,synced,importFileToResult(),3470,,http://127.0.0.1:1787/asset/2
1 Like

Wow, thanks for taking the time to assemble such a nice bug report! I’ll try to reproduce this locally.

1 Like