Skip to content

Bosu - fix: expose user profile id in HGN questionnaire responses - #2315

Open
BosuBose132 wants to merge 1 commit into
developmentfrom
Bosu-Fix-HGN-Questionnaire-Profile-ID
Open

Bosu - fix: expose user profile id in HGN questionnaire responses#2315
BosuBose132 wants to merge 1 commit into
developmentfrom
Bosu-Fix-HGN-Questionnaire-Profile-ID

Conversation

@BosuBose132

@BosuBose132 BosuBose132 commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Description

Fixes the backend identifier mismatch affecting HGN Questionnaire Dashboard profile navigation.

The HGN ranked and community endpoints return records from HGNFormResponses. Their existing _id field represents the questionnaire response document ID, while /api/skills/profile/:userId expects the corresponding UserProfile._id.

Because the actual profile ID was not exposed by the ranked/community responses, the frontend was previously navigating with the questionnaire response _id. The profile endpoint could not resolve that value as a user profile and returned placeholder data such as Unknown User.

This PR preserves the existing _id field and adds the associated user_id value as userId to the relevant API responses.

Related PRs

  1. This backend PR is related to frontend PR #5462.
  2. The frontend PR uses the new userId field for /hgnhelp/profile/:userId.
  3. Both PRs should be tested together.

Main changes explained

  1. Updated hgnFormResponseController.js ranked responses to preserve:

    _id: user._id

    and additionally expose:

    userId: user.user_id

  2. Updated communityController.js to preserve:

    _id: member._id

    and additionally expose:

    userId: member.user_id

  3. Preserved all existing response fields and behavior for backward compatibility.

  4. Added focused assertions to the existing HGN form response controller tests.

  5. Added focused tests for the community controller response.

  6. No database schema, route, or user skills profile controller changes were made.

How to test

  1. Checkout this backend branch.

  2. Checkout the related frontend PR branch.

  3. Run:

    npm run build

  4. Start the backend locally.

  5. Start the related frontend locally.

  6. Navigate to the HGN questionnaire community member list.

  7. Inspect the ranked/community API response in DevTools.

  8. Verify each applicable user object contains both:

    • _id — questionnaire response document ID
    • userId — actual user profile ID
  9. Click a user's name in the frontend.

  10. Verify the frontend uses userId when navigating to:

    /hgnhelp/profile/<userId>

  11. Verify the subsequent request to:

    /api/skills/profile/<userId>

    returns the real user profile instead of placeholder Unknown User data.

  12. Test multiple users and verify skills, experience, and team information are returned when available.

Validation performed

  • Focused backend controller tests: 9/9 passed
  • ESLint: 0 new errors
  • git diff --check: passed
  • Backend build with npm run build: passed
  • End-to-end local FE/BE integration test: passed
  • Real user profile resolution: passed
  • Skills and experience data: passed
  • Team data: passed

Screenshots or videos of changes

Screenshot 2026-08-22 at 11 45 33 AM

Note

This is an additive and backward-compatible response change. The existing _id field remains unchanged because other functionality may depend on the questionnaire response document ID. No schema, database migration, route, or unrelated controller changes are included.

@sonarqubecloud

Copy link
Copy Markdown

@BosuBose132 BosuBose132 changed the title fix: expose user profile id in HGN questionnaire responses Bosu - fix: expose user profile id in HGN questionnaire responses Aug 22, 2026
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