Skip to content

Issue #000000 Fix: Fix about cohort member API response code and error message#504

Open
vaibhavsTekdi wants to merge 2 commits intotekdi:aspire-leadersfrom
vaibhavsTekdi:vs-fixes
Open

Issue #000000 Fix: Fix about cohort member API response code and error message#504
vaibhavsTekdi wants to merge 2 commits intotekdi:aspire-leadersfrom
vaibhavsTekdi:vs-fixes

Conversation

@vaibhavsTekdi
Copy link
Collaborator

@vaibhavsTekdi vaibhavsTekdi commented Oct 8, 2025

Summary by CodeRabbit

  • New Features
    • Added a specific error message indicating a user is not a member of any cohort, improving clarity in responses and UI handling.
  • Bug Fixes
    • Corrected the response for non-member users in cohort searches to return a Not Found status, ensuring accurate status codes and more consistent behavior across the app.

@coderabbitai
Copy link

coderabbitai bot commented Oct 8, 2025

Walkthrough

Updates the cohort member search to return USER_NOT_MEMBER_OF_COHORT with NOT_FOUND when a user is absent, and introduces the corresponding response key and message in the shared response mappings. No exported API signatures changed.

Changes

Cohort / File(s) Summary
Cohort search flow update
src/adapters/postgres/cohortMembers-adapter.ts
Adjusts not-found user branch to return API_RESPONSES.USER_NOT_MEMBER_OF_COHORT with HTTP NOT_FOUND instead of USER_NOTFOUND with OK.
Response messages addition
src/common/utils/response.messages.ts
Adds USER_NOT_MEMBER_OF_COHORT to API_RESPONSES with message "User is not a member of any cohort".

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant C as Client
  participant A as CohortMembersAdapter
  participant DB as Postgres
  participant R as ResponseMessages

  C->>A: searchCohortMember(userId)
  A->>DB: SELECT member WHERE userId=?
  alt Member found
    DB-->>A: Row
    A-->>C: 200 OK + member data
  else Member not found (updated)
    DB-->>A: No rows
    A->>R: API_RESPONSES.USER_NOT_MEMBER_OF_COHORT
    A-->>C: 404 NOT_FOUND + USER_NOT_MEMBER_OF_COHORT
  end

  note over A,R: Previously returned 200 OK + USER_NOTFOUND
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title explicitly references the key change to the cohort member API response code and error message, matching the PR’s main adjustment. It remains concise and relevant without introducing unrelated details.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Oct 8, 2025

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between 9269a67 and f3c3c93.

📒 Files selected for processing (2)
  • src/adapters/postgres/cohortMembers-adapter.ts (1 hunks)
  • src/common/utils/response.messages.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.ts

⚙️ CodeRabbit configuration file

**/*.ts: "Review the JavaScript code for conformity with the Google JavaScript style guide, highlighting any deviations. Ensure that:

  • The code adheres to best practices associated with nodejs.
  • The code adheres to best practices associated with nestjs framework.
  • The code adheres to best practices recommended for performance.
  • The code adheres to similar naming conventions for controllers, models, services, methods, variables."

Files:

  • src/common/utils/response.messages.ts
  • src/adapters/postgres/cohortMembers-adapter.ts
🔇 Additional comments (1)
src/common/utils/response.messages.ts (1)

51-51: LGTM! Clear and specific error message.

The new USER_NOT_MEMBER_OF_COHORT constant provides a clear, context-specific message for cohort membership scenarios, which is more precise than the generic USER_NOTFOUND message.

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.

1 participant