Skip to content

Comments

Fix race condition and add validation in user special membership request patch method#668

Merged
danieleguido merged 3 commits intofeature/review-patchfrom
copilot/sub-pr-667
Feb 15, 2026
Merged

Fix race condition and add validation in user special membership request patch method#668
danieleguido merged 3 commits intofeature/review-patchfrom
copilot/sub-pr-667

Conversation

Copy link
Contributor

Copilot AI commented Feb 13, 2026

Addresses review feedback from PR #667. The patch method had a race condition with async Celery calls, lacked input validation, and didn't maintain audit timestamps.

Changes

  • Await Celery client call: Fixed race condition where test assertions could execute before task queueing completed. Changed from .catch() pattern to proper await with try-catch.

  • Update dateLastModified: Automatically set on patch operations to maintain audit trail consistency with create operations.

  • Validate status field: Reject invalid status values with BadRequest. Only pending, approved, rejected are permitted.

  • Use Winston logger: Replaced console.error with logger.error for consistent log management.

// Before
await record.update(data)
if (this.celeryClient)
  this.celeryClient.run({ task: '...', args: [record.id] })
    .catch(err => console.error('Error:', err))

// After
const updateData = { ...data, dateLastModified: new Date() }
await record.update(updateData)
if (this.celeryClient) {
  try {
    await this.celeryClient.run({ task: '...', args: [record.id] })
  } catch (err) {
    logger.error('Error:', err)
  }
}

Added test coverage for status validation and dateLastModified behavior.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits February 13, 2026 16:11
…ateLastModified, use logger

Co-authored-by: danieleguido <1181642+danieleguido@users.noreply.github.com>
Co-authored-by: danieleguido <1181642+danieleguido@users.noreply.github.com>
Copilot AI changed the title [WIP] Add patch method to update membership request status Fix race condition and add validation in user special membership request patch method Feb 13, 2026
Copilot AI requested a review from danieleguido February 13, 2026 16:14
@danieleguido danieleguido marked this pull request as ready for review February 15, 2026 16:43
@danieleguido danieleguido merged commit b86caeb into feature/review-patch Feb 15, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants