diff --git a/.vscode/settings.json b/.vscode/settings.json index bbab22fea..81fb89d64 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -7,6 +7,7 @@ "typescript.tsdk": "node_modules/typescript/lib", "editor.tabSize": 2, "cSpell.words": [ + "backlinks", "Cdfc", "cjsx", "clsx", diff --git a/apps/backend/prisma/migrations/20241223205737_remove_empty_profile_images/migration.sql b/apps/backend/prisma/migrations/20241223205737_remove_empty_profile_images/migration.sql new file mode 100644 index 000000000..9455f430e --- /dev/null +++ b/apps/backend/prisma/migrations/20241223205737_remove_empty_profile_images/migration.sql @@ -0,0 +1,4 @@ +-- Some older versions allowed the empty string as a profile image. +-- We fix that. + +UPDATE "ProjectUser" SET "profileImageUrl" = NULL WHERE "profileImageUrl" = ''; diff --git a/apps/backend/prisma/schema.prisma b/apps/backend/prisma/schema.prisma index 5f008a58d..c3b25ce63 100644 --- a/apps/backend/prisma/schema.prisma +++ b/apps/backend/prisma/schema.prisma @@ -1,6 +1,3 @@ -// This is your Prisma schema file, -// learn more about it in the docs: https://pris.ly/d/prisma-schema - generator client { provider = "prisma-client-js" previewFeatures = ["tracing", "relationJoins"] diff --git a/apps/e2e/tests/backend/endpoints/api/v1/users.test.ts b/apps/e2e/tests/backend/endpoints/api/v1/users.test.ts index 425c40053..dd5a2d9d4 100644 --- a/apps/e2e/tests/backend/endpoints/api/v1/users.test.ts +++ b/apps/e2e/tests/backend/endpoints/api/v1/users.test.ts @@ -1666,4 +1666,29 @@ describe("with server access", () => { } `); }); + + it("should not be able to set profile image url to empty string", async ({ expect }) => { + await Auth.Otp.signIn(); + const response = await niceBackendFetch("/api/v1/users/me", { + accessType: "server", + method: "PATCH", + body: { + profile_image_url: "", + }, + }); + expect(response).toMatchInlineSnapshot(` + NiceResponse { + "status": 400, + "body": { + "code": "SCHEMA_ERROR", + "details": { "message": "Request validation failed on PATCH /api/v1/users/me:\\n - body.profile_image_url is not a valid URL" }, + "error": "Request validation failed on PATCH /api/v1/users/me:\\n - body.profile_image_url is not a valid URL", + }, + "headers": Headers { + "x-stack-known-error": "SCHEMA_ERROR", +