Skip to content

fix: preserve generated proposal ids#6662

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

fix: preserve generated proposal ids#6662
MolhamHamwi wants to merge 2 commits into
SecureBananaLabs:mainfrom
MolhamHamwi:fix/6661-proposal-id-preserve

Conversation

@MolhamHamwi

Copy link
Copy Markdown

Summary

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

Fixes #6661
/claim #6661
/claim #743

Test Plan

  • node --test apps/api/src/tests/proposalService.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 a regression test to ensure createProposal always uses a server-generated proposal ID (even if the client supplies an id) and updates the service implementation to enforce that behavior.

Changes:

  • Added a node:test test covering ID override behavior and persistence via listProposals().
  • Updated createProposal spread order so the generated id cannot be overridden by payload.id.

Reviewed changes

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

File Description
apps/api/src/tests/proposalService.test.js Adds regression test asserting server-generated IDs are preserved and stored.
apps/api/src/services/proposalService.js Changes object spread order to ensure generated id wins over client payload.

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

Comment on lines +5 to +21
test("createProposal preserves the generated proposal id over payload id", async () => {
const proposal = await createProposal({
id: "prp_client_supplied",
jobId: "job_123",
freelancerId: "usr_123",
coverLetter: "Focused proposal",
});

assert.match(proposal.id, /^prp_\d+$/);
assert.notEqual(proposal.id, "prp_client_supplied");
assert.equal(proposal.jobId, "job_123");
assert.equal(proposal.freelancerId, "usr_123");
assert.equal(proposal.coverLetter, "Focused proposal");

const stored = (await listProposals()).find((entry) => entry.jobId === "job_123");
assert.equal(stored?.id, proposal.id);
}); No newline at end of file

export async function createProposal(payload) {
const proposal = { id: `prp_${Date.now()}`, ...payload };
const proposal = { ...payload, id: `prp_${Date.now()}` };
@MolhamHamwi

Copy link
Copy Markdown
Author

Addressed the review feedback: proposal IDs now use randomUUID(), the test resets the proposal store before each run, and the fixture uses a unique job id with semantic assertions. Local check: node --test src/tests/proposalService.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.

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

2 participants