From 6703503a358ba8289ad6cb3c1ba4aff18efbd0b9 Mon Sep 17 00:00:00 2001 From: Rohil Surana Date: Mon, 23 Nov 2026 11:54:07 +0530 Subject: [PATCH 1/2] fix(sdk): send only profile fields when updating the current user --- web/sdk/client/views/profile/profile-view.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/web/sdk/client/views/profile/profile-view.tsx b/web/sdk/client/views/profile/profile-view.tsx index 2aa69b835..9b010b4fb 100644 --- a/web/sdk/client/views/profile/profile-view.tsx +++ b/web/sdk/client/views/profile/profile-view.tsx @@ -101,7 +101,14 @@ export function ProfileView({ async function onSubmit(data: FormData) { try { if (!user?.id) return; - await updateCurrentUser({ body: data }); + await updateCurrentUser({ + body: { + title: data.title, + email: data.email, + avatar: data.avatar, + name: user.name + } + }); toastManager.add({ title: 'Updated user', type: 'success' }); } catch (err) { handleConnectError(err, { From fa3bfb722f50a683304a381ac6443a3b68d12e66 Mon Sep 17 00:00:00 2001 From: Rohil Surana Date: Mon, 23 Nov 2026 13:12:06 +0530 Subject: [PATCH 2/2] test(sdk): check that a profile save leaves out metadata --- .../views/profile/profile-update-body.test.ts | 35 +++++++++++++++++++ .../views/profile/profile-update-body.ts | 17 +++++++++ web/sdk/client/views/profile/profile-view.tsx | 10 ++---- 3 files changed, 54 insertions(+), 8 deletions(-) create mode 100644 web/sdk/client/views/profile/profile-update-body.test.ts create mode 100644 web/sdk/client/views/profile/profile-update-body.ts diff --git a/web/sdk/client/views/profile/profile-update-body.test.ts b/web/sdk/client/views/profile/profile-update-body.test.ts new file mode 100644 index 000000000..297d00413 --- /dev/null +++ b/web/sdk/client/views/profile/profile-update-body.test.ts @@ -0,0 +1,35 @@ +import { profileUpdateBody } from './profile-update-body'; + +describe('profileUpdateBody', () => { + const storedUser = { + id: 'user-1', + name: 'jane_doe', + title: 'Jane Doe', + email: 'jane@raystack.org', + avatar: 'data:image/png;base64,old', + metadata: { onboarded: true, team: 'core' } + }; + + it('leaves out metadata when only the avatar changes', () => { + const formValues = { ...storedUser, avatar: 'data:image/png;base64,new' }; + + const body = profileUpdateBody(formValues, storedUser.name); + + expect(body).toEqual({ + title: 'Jane Doe', + email: 'jane@raystack.org', + avatar: 'data:image/png;base64,new', + name: 'jane_doe' + }); + expect(body).not.toHaveProperty('metadata'); + }); + + it('leaves out metadata when the title changes', () => { + const formValues = { ...storedUser, title: 'Jane Smith' }; + + const body = profileUpdateBody(formValues, storedUser.name); + + expect(body.title).toBe('Jane Smith'); + expect(body).not.toHaveProperty('metadata'); + }); +}); diff --git a/web/sdk/client/views/profile/profile-update-body.ts b/web/sdk/client/views/profile/profile-update-body.ts new file mode 100644 index 000000000..974d72e81 --- /dev/null +++ b/web/sdk/client/views/profile/profile-update-body.ts @@ -0,0 +1,17 @@ +export interface ProfileFormValues { + title: string; + email: string; + avatar?: string; +} + +export function profileUpdateBody( + values: ProfileFormValues, + currentName: string | undefined +) { + return { + title: values.title, + email: values.email, + avatar: values.avatar, + name: currentName + }; +} diff --git a/web/sdk/client/views/profile/profile-view.tsx b/web/sdk/client/views/profile/profile-view.tsx index 9b010b4fb..4a2f30126 100644 --- a/web/sdk/client/views/profile/profile-view.tsx +++ b/web/sdk/client/views/profile/profile-view.tsx @@ -27,6 +27,7 @@ import { DeleteUserDialog } from '../../components/delete-user-dialog'; import styles from './profile-view.module.css'; import { handleConnectError } from '~/utils/error'; +import { profileUpdateBody } from './profile-update-body'; const profileSchema = yup .object({ @@ -101,14 +102,7 @@ export function ProfileView({ async function onSubmit(data: FormData) { try { if (!user?.id) return; - await updateCurrentUser({ - body: { - title: data.title, - email: data.email, - avatar: data.avatar, - name: user.name - } - }); + await updateCurrentUser({ body: profileUpdateBody(data, user.name) }); toastManager.add({ title: 'Updated user', type: 'success' }); } catch (err) { handleConnectError(err, {