Skip to content

fix: preserve generated user ids#6660

Open
MolhamHamwi wants to merge 2 commits into
SecureBananaLabs:mainfrom
MolhamHamwi:fix/6658-user-id-preserve
Open

fix: preserve generated user ids#6660
MolhamHamwi wants to merge 2 commits into
SecureBananaLabs:mainfrom
MolhamHamwi:fix/6658-user-id-preserve

Conversation

@MolhamHamwi

Copy link
Copy Markdown

Summary

  • preserves the server-generated user id when creating users
  • adds focused service regression coverage for client-supplied ids

Fixes #6658
/claim #6658
/claim #743

Test Plan

  • node --test apps/api/src/tests/userService.test.js
  • node --test apps/api/src/tests/*.test.js
  • git diff --check

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds coverage to ensure createUser does not allow a client-supplied id to override the server-generated one, and updates the implementation to enforce that behavior.

Changes:

  • Reorders object spread in createUser so the generated id wins over payload.id
  • Adds a Node.js test validating id preservation and persistence via listUsers

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
apps/api/src/services/userService.js Ensures server-generated id overrides any client-provided id in the payload
apps/api/src/tests/userService.test.js Adds a regression test verifying createUser ignores payload.id and persists the generated id

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread apps/api/src/services/userService.js Outdated

export async function createUser(payload) {
const user = { id: `usr_${Date.now()}`, ...payload };
const user = { ...payload, id: `usr_${Date.now()}` };
Comment on lines +6 to +10
const user = await createUser({
id: "usr_client_supplied",
name: "Payload Name",
email: "payload@example.com",
});
Comment thread apps/api/src/tests/userService.test.js Outdated
assert.equal(user.name, "Payload Name");
assert.equal(user.email, "payload@example.com");

const stored = (await listUsers()).find((entry) => entry.email === "payload@example.com");
Comment thread apps/api/src/tests/userService.test.js Outdated
email: "payload@example.com",
});

assert.match(user.id, /^usr_\d+$/);
@MolhamHamwi

Copy link
Copy Markdown
Author

Addressed the review feedback: user IDs now use randomUUID(), the test resets the user store before each run, uses a unique email, and asserts the semantic ID contract. Local check: node --test src/tests/userService.test.js passed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

User creation should preserve server-generated ids (MolhamHamwi reissue via #743)

2 participants