Remove empty profile image strings from database

This commit is contained in:
Konstantin Wohlwend 2024-12-23 13:08:36 -08:00
parent ef935e24d8
commit 415dc2df42
4 changed files with 30 additions and 3 deletions

View File

@ -7,6 +7,7 @@
"typescript.tsdk": "node_modules/typescript/lib",
"editor.tabSize": 2,
"cSpell.words": [
"backlinks",
"Cdfc",
"cjsx",
"clsx",

View File

@ -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" = '';

View File

@ -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"]

View File

@ -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",
<some fields may have been hidden>,
},
}
`);
});
});