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

fix(server): places page not working with partner sharing #8257

Merged
merged 2 commits into from
Mar 25, 2024

Conversation

mertalev
Copy link
Contributor

Description

The user IDs are concatenated for the query, but this doesn't work since they're interpreted as a single invalid UUID rather than multiple UUIDs (if it did work, it would imply SQL injection). This PR changes the query to allow the array of user IDs to be passed directly.

Fixes #8241

How Has This Been Tested?

Tested that the query still works when visiting the Places page.

Copy link

cloudflare-pages bot commented Mar 25, 2024

Deploying immich with  Cloudflare Pages  Cloudflare Pages

Latest commit: 81e26e5
Status: ✅  Deploy successful!
Preview URL: https://3fe712f7.immich.pages.dev
Branch Preview URL: https://fix-server-places-partner-sh.immich.pages.dev

View logs

@mertalev mertalev merged commit 4a6a0aa into main Mar 25, 2024
24 checks passed
@mertalev mertalev deleted the fix/server-places-partner-sharing branch March 25, 2024 05:59
@justinhorton
Copy link

I'm still seeing a Failed to get assets by city (500) error when clicking on View All in v1.100.0

The postgres error is now:

2024-03-28 12:11:29.687 PDT [20017] ERROR:  malformed array literal: "$1" at character 149
2024-03-28 12:11:29.687 PDT [20017] DETAIL:  Array value must start with "{" or dimension information.

@mertalev
Copy link
Contributor Author

Hmm, that's strange. It was working when I tested it. Let me take another look at this.

@twincityjeff70
Copy link

I dont know if this will help but its from the server log:
[Nest] 8 - 03/28/2024, 8:05:13 PM ERROR [QueryFailedError: malformed array literal: "$1"
at PostgresQueryRunner.query (/usr/src/app/node_modules/typeorm/driver/postgres/PostgresQueryRunner.js:219:19)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async DataSource.query (/usr/src/app/node_modules/typeorm/data-source/DataSource.js:350:20)
at async SearchRepository.getAssetsByCity (/usr/src/app/dist/repositories/search.repository.js:169:24)
at async SearchService.getAssetsByCity (/usr/src/app/dist/services/search.service.js:97:24)] Failed to get assets by city
[Nest] 8 - 03/28/2024, 8:05:13 PM ERROR [QueryFailedError: malformed array literal: "$1"
at PostgresQueryRunner.query (/usr/src/app/node_modules/typeorm/driver/postgres/PostgresQueryRunner.js:219:19)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async DataSource.query (/usr/src/app/node_modules/typeorm/data-source/DataSource.js:350:20)
at async SearchRepository.getAssetsByCity (/usr/src/app/dist/repositories/search.repository.js:169:24)
at async SearchService.getAssetsByCity (/usr/src/app/dist/services/search.service.js:97:24)] QueryFailedError: malformed array literal: "$1"

@Quadrapole
Copy link

Quadrapole commented Mar 29, 2024

I have the same problem when partner sharing and clicking on places on the web interface. I am on 1.100 as well.

I get the error:

Failed to get assets by city (500)

Stacktrace
Error: Error: 500
at Object.ie [as ok] (myip/_app/immutable/chunks/fetch-client.DbGu7UYN.js:1:port)
at async re (http://myip/_app/immutable/nodes/23.CqGNU3zZ.js:1:port)
at async Ie (http://myip/_app/immutable/chunks/entry.DgOIyjKe.js:1:port)

@MrColumbo
Copy link

the same for me (also on 1.100 as well

Error: Error: 500
at Object.ie [as ok] (https://.../_app/immutable/chunks/fetch-client.DbGu7UYN.js:1:2832)
at async re (https://.../_app/immutable/nodes/23.CF3jLVVG.js:1:789)
at async Ie (https://.../_app/immutable/chunks/entry.gs5-sG3j.js:1:13443)

@mertalev
Copy link
Contributor Author

mertalev commented Apr 1, 2024

Thanks for reaching out y'all! This is fixed on main and will be in the next release.

@GeorgeAL78
Copy link

GeorgeAL78 commented Apr 1, 2024

No partner sharing, but same error:
app error v1.100.0:
Failed to get assets by city (500)

Stacktrace
Error: Error: 500
at Object.ie [as ok] (http://192.168.1.128:8080/_app/immutable/chunks/fetch-client.DbGu7UYN.js:1:2832)
at async re (http://192.168.1.128:8080/_app/immutable/nodes/23.CqGNU3zZ.js:1:789)
at async Ie (http://192.168.1.128:8080/_app/immutable/chunks/entry.DgOIyjKe.js:1:13443)

db error, postgres 16:

2024-04-01 11:47:55.418 EDT [5264] ERROR: malformed array literal: "$1" at character 149
2024-04-01 11:47:55.418 EDT [5264] DETAIL: Array value must start with "{" or dimension information.
2024-04-01 11:47:55.418 EDT [5264] STATEMENT:
WITH RECURSIVE cte AS (
(
SELECT city, "assetId"
FROM exif
INNER JOIN assets ON exif."assetId" = assets.id
WHERE "ownerId" = ANY('$1'::uuid[]) AND "isVisible" = $2 AND "isArchived" = $3 AND type = $4
ORDER BY city
LIMIT 1
)

      UNION ALL

      SELECT l.city, l."assetId"
      FROM cte c
        , LATERAL (
        SELECT city, "assetId"
        FROM exif
        INNER JOIN assets ON exif."assetId" = assets.id
        WHERE city > c.city AND "ownerId" = ANY('$1'::uuid[]) AND "isVisible" = $2 AND "isArchived" = $3 AND type = $4
        ORDER BY city
        LIMIT 1
        ) l
    )
    SELECT "asset"."id" AS "asset_id", "asset"."deviceAssetId" AS "asset_deviceAssetId", "asset"."ownerId" AS "asset_ownerId", "asset"."libraryId" AS "asset_libraryId", "asset"."deviceId" AS "asset_deviceId", "asset"."type" AS "asset_type", "asset"."originalPath" AS "asset_originalPath", "asset"."resizePath" AS "asset_resizePath", "asset"."webpPath" AS "asset_webpPath", "asset"."thumbhash" AS "asset_thumbhash", "asset"."encodedVideoPath" AS "asset_encodedVideoPath", "asset"."createdAt" AS "asset_createdAt", "asset"."updatedAt" AS "asset_updatedAt", "asset"."deletedAt" AS "asset_deletedAt", "asset"."fileCreatedAt" AS "asset_fileCreatedAt", "asset"."localDateTime" AS "asset_localDateTime", "asset"."fileModifiedAt" AS "asset_fileModifiedAt", "asset"."isFavorite" AS "asset_isFavorite", "asset"."isArchived" AS "asset_isArchived", "asset"."isExternal" AS "asset_isExternal", "asset"."isReadOnly" AS "asset_isReadOnly", "asset"."isOffline" AS "asset_isOffline", "asset"."checksum" AS "asset_checksum", "asset"."duration" AS "asset_duration", "asset"."isVisible" AS "asset_isVisible", "asset"."livePhotoVideoId" AS "asset_livePhotoVideoId", "asset"."originalFileName" AS "asset_originalFileName", "asset"."sidecarPath" AS "asset_sidecarPath", "asset"."stackId" AS "asset_stackId", "exif"."assetId" AS "exif_assetId", "exif"."description" AS "exif_description", "exif"."exifImageWidth" AS "exif_exifImageWidth", "exif"."exifImageHeight" AS "exif_exifImageHeight", "exif"."fileSizeInByte" AS "exif_fileSizeInByte", "exif"."orientation" AS "exif_orientation", "exif"."dateTimeOriginal" AS "exif_dateTimeOriginal", "exif"."modifyDate" AS "exif_modifyDate", "exif"."timeZone" AS "exif_timeZone", "exif"."latitude" AS "exif_latitude", "exif"."longitude" AS "exif_longitude", "exif"."projectionType" AS "exif_projectionType", "exif"."city" AS "exif_city", "exif"."livePhotoCID" AS "exif_livePhotoCID", "exif"."autoStackId" AS "exif_autoStackId", "exif"."state" AS "exif_state", "exif"."country" AS "exif_country", "exif"."make" AS "exif_make", "exif"."model" AS "exif_model", "exif"."lensModel" AS "exif_lensModel", "exif"."fNumber" AS "exif_fNumber", "exif"."focalLength" AS "exif_focalLength", "exif"."iso" AS "exif_iso", "exif"."exposureTime" AS "exif_exposureTime", "exif"."profileDescription" AS "exif_profileDescription", "exif"."colorspace" AS "exif_colorspace", "exif"."bitsPerSample" AS "exif_bitsPerSample", "exif"."fps" AS "exif_fps" FROM "assets" "asset" INNER JOIN "exif" "exif" ON "exif"."assetId"="asset"."id" INNER JOIN cte ON asset.id = cte."assetId"

@Krolitian
Copy link

Krolitian commented Apr 2, 2024

My partner sharing isn't even enabled and I'm getting this issue.

Error: Error: 500
    at Object.ie [as ok] (https://URL.com/_app/immutable/chunks/fetch-client.DbGu7UYN.js:1:2832)
    at async re (https://URL.com/_app/immutable/nodes/23.CqGNU3zZ.js:1:789)
    at async Ie (https://URL.com/_app/immutable/chunks/entry.DgOIyjKe.js:1:13443)
[Nest] 220  - 04/02/2024, 2:52:59 PM   ERROR [QueryFailedError: malformed array literal: "$1"
    at PostgresQueryRunner.query (/app/immich/server/node_modules/typeorm/driver/postgres/PostgresQueryRunner.js:219:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async DataSource.query (/app/immich/server/node_modules/typeorm/data-source/DataSource.js:350:20)
    at async SearchRepository.getAssetsByCity (/app/immich/server/dist/repositories/search.repository.js:169:24)
    at async SearchService.getAssetsByCity (/app/immich/server/dist/services/search.service.js:97:24)] QueryFailedError: malformed array literal: "$1"

@mertalev
Copy link
Contributor Author

mertalev commented Apr 2, 2024

This issue is fixed on main and will be in the next release.

@immich-app immich-app locked and limited conversation to collaborators Apr 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Failed to get assets by city (500) when partner sharing is enabled
8 participants